summaryrefslogtreecommitdiff
path: root/H40.hs
diff options
context:
space:
mode:
Diffstat (limited to 'H40.hs')
-rw-r--r--H40.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/H40.hs b/H40.hs
new file mode 100644
index 0000000..448d372
--- /dev/null
+++ b/H40.hs
@@ -0,0 +1,9 @@
+import H35
+
+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)