haskell 003

master
Evan Hemsley 2020-10-26 23:19:53 -07:00
parent 5061e75030
commit 1d9e341ac3
1 changed files with 9 additions and 0 deletions

9
haskell/euler003.hs Normal file
View File

@ -0,0 +1,9 @@
module Main where
primes = 2 : [i | i <- [3..],
and [rem i p > 0 | p <- takeWhile (\p -> p^2 <= i) primes]]
primeFactors n = filter (\a -> n `mod` a == 0) (takeWhile (\m -> m * m < n) primes)
main = do
print (last (primeFactors 600851475143))