euler/haskell/euler003.hs

10 lines
262 B
Haskell
Raw Normal View History

2020-10-27 06:19:53 +00:00
module Main where
primes = 2 : [i | i <- [3..],
and [rem i p > 0 | p <- takeWhile (\p -> p^2 <= i) primes]]
2020-10-27 06:24:12 +00:00
primeFactors n = filter (\a -> mod n a == 0) (takeWhile (\m -> m * m < n) primes)
2020-10-27 06:19:53 +00:00
main = do
print (last (primeFactors 600851475143))