diff options
author | Guillermo Ramos | 2013-05-27 10:31:48 +0200 |
---|---|---|
committer | Guillermo Ramos | 2013-05-27 10:31:48 +0200 |
commit | 317ee36636ebeec986971ef857cd297f0320e58d (patch) | |
tree | 88c10fdbf166beae22f6c9d6c79970ae2240f4b0 /haskell/p10.hs | |
download | euler-317ee36636ebeec986971ef857cd297f0320e58d.tar.gz |
start
Diffstat (limited to 'haskell/p10.hs')
-rw-r--r-- | haskell/p10.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/haskell/p10.hs b/haskell/p10.hs new file mode 100644 index 0000000..e7a7c85 --- /dev/null +++ b/haskell/p10.hs @@ -0,0 +1,12 @@ +sieve :: Int -> [Int] +sieve max = sieve_l [2..max] (floor . sqrt . fromIntegral $ max) + where + sieve_l [n] _ = [n] + sieve_l (n:xl) max_sqrt + | n > max_sqrt = n:xl + | otherwise = n : sieve_l (filter ((/= 0).(`mod` n)) xl) max_sqrt + +p10 :: Int +p10 = sum $ sieve 2000000 + +main = putStrLn $ "Solution: " ++ show p10 |