Created
October 23, 2010 02:07
-
-
Save takuma7/641677 to your computer and use it in GitHub Desktop.
Project Euler - Problem 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.IO | |
main = do | |
putStrLn $ show $ last $ filter ((== 0) . (mod 600851475143)) (takeWhile (< (truncate (sqrt 600851475143))) prime) | |
prime = 2:f [3] [3,5..] | |
where f (x:xs) ys = let (ps, qs) = span (< x^2) ys | |
in ps ++ f (xs ++ ps) [z | z <- qs, z `mod` x /= 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment