Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ### Project Euler, problem 216 ### --
- isPrime n = all (/= 0) . map (n `mod`) $ [2..squareRoot n]
- where
- squareRoot = truncate . sqrt . fromIntegral
- list = map (subtract 1 . (*2) . (^2)) [2..] -- 2n^2-1
- main = do
- putStrLn . show $ solveit 10000 -- control-case
- putStrLn . show $ solveit 50000000 -- problem
- where
- solveit n = length . filter isPrime $ take (n-1) list
Advertisement
Add Comment
Please, Sign In to add comment