This file contains 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] |
No comments:
Post a Comment