Hello I am trying to make a function goldbach :: Integer -> Bool
for interval [4..n]
that should return True
only if all elements in that interval is even and can be summed from two prim numbers. So far I have done this.
goldbach::Integer->Bool
goldbach n
|goldbach2 n == ??? = goldbach (n-2)
|n==4 = True
|otherwise = False
goldbach2 :: Integer -> (Integer, Integer)
goldbach2 a = head $
filter (\(x,y) -> isPrime x && isPrime y) $
map (\e -> (e, a - e)) [3,5..a `div` 2]
where
factors a = filter (isFactor a) [2..a-1]
isFactor a b = a `mod` b == 0
isPrime a = null $ factors a
Function golbach2
result looks like this goldbac2 28 = (5, 23)
. How should I chek in my 3rd line goldbach2 n == ??? = goldbach (n-2)
if result of goldbach2 n
is correct and gives me two prim numbers?