diff options
Diffstat (limited to '0010/main.hs')
| -rw-r--r-- | 0010/main.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/0010/main.hs b/0010/main.hs new file mode 100644 index 0000000..74780f5 --- /dev/null +++ b/0010/main.hs @@ -0,0 +1,20 @@ +primes = primesImpl 2 [] + where + primesImpl :: Integer -> [Integer] -> [Integer] + primesImpl i primeList = + if isPrime then + i:(primesImpl (i+1) (primeList ++ [i])) + else + primesImpl (i+1) primeList + where + isPrime = isPrimeImpl primeList + where + isPrimeImpl [] = True + isPrimeImpl (x:xs) = + if i `mod` x == 0 then + False + else + isPrimeImpl xs + +main = do + putStrLn $ show $ sum $ takeWhile (<2000000) primes |
