summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--H35.hs1
-rw-r--r--H39.hs3
-rw-r--r--H40.hs9
3 files changed, 13 insertions, 0 deletions
diff --git a/H35.hs b/H35.hs
index 1d96e4e..caa59c0 100644
--- a/H35.hs
+++ b/H35.hs
@@ -1,5 +1,6 @@
module H35
( primeFactors
+, primes
) where
primeSift (x:xs) = (x:) $ primeSift $ filter ((/=0).(`mod` x)) xs
diff --git a/H39.hs b/H39.hs
new file mode 100644
index 0000000..08da249
--- /dev/null
+++ b/H39.hs
@@ -0,0 +1,3 @@
+import H35
+
+primesR a b = dropWhile (<a) $ takeWhile (<=b) primes
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)