module Solutions.P45 (isGaussianPrime') where
import Data.Complex
import Problems.P31
isGaussianPrime' :: Complex Integer -> Bool
isGaussianPrime' :: Complex Integer -> Bool
isGaussianPrime' (Integer
a :+ Integer
0) = Integer -> Integer
forall a. Num a => a -> a
abs Integer
a Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`mod` Integer
4 Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
3 Bool -> Bool -> Bool
&& Integer -> Bool
forall a. Integral a => a -> Bool
isPrime (Integer -> Integer
forall a. Num a => a -> a
abs Integer
a)
isGaussianPrime' (Integer
0 :+ Integer
b) = Integer -> Integer
forall a. Num a => a -> a
abs Integer
b Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`mod` Integer
4 Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
3 Bool -> Bool -> Bool
&& Integer -> Bool
forall a. Integral a => a -> Bool
isPrime (Integer -> Integer
forall a. Num a => a -> a
abs Integer
b)
isGaussianPrime' (Integer
a :+ Integer
b) = Integer -> Bool
forall a. Integral a => a -> Bool
isPrime (Integer
aInteger -> Integer -> Integer
forall a. Num a => a -> a -> a
*Integer
a Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
bInteger -> Integer -> Integer
forall a. Num a => a -> a -> a
*Integer
b)