Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The task: the sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
- -- Find the sum of all the primes below two million.
- primeCheck :: Int -> Bool
- primeCheck x =
- null [y | y <- [3,5 .. (ceiling . sqrt . fromIntegral) x], mod x y == 0]
- primes :: [Int]
- primes = filter primeCheck [1999999,1999997 .. 9]
- main :: IO ()
- main = print $ sum (17 : primes)
- -- 142913828922
- -- real 0m9,724s
- -- user 0m9,620s
- -- sys 0m0,092s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement