summaryrefslogtreecommitdiff
path: root/H40.hs
blob: 4a31727857dc7fd9079d93c335f377e5c9b9066c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module H40
(   goldbach
) where

import H35
import H31

goldbach :: Integer -> (Integer, Integer)
goldbach x = sepToSum x primes $ reverse $ takeWhile (<x) primes
    where 
        sepToSum n hhs@(h:hs) tts@(t:ts)
            | h+t > n = sepToSum n hhs ts
            | h+t < n = sepToSum n hs tts
            | otherwise = (h,t)

goldbach' n = head [(x,y) | x <- (takeWhile (<n) primes),let y = n - x, isPrimeT y]