more idiomatic haskell 003
parent
9763b56dce
commit
7ed2845210
|
@ -3,7 +3,7 @@ module Main where
|
||||||
primes = 2 : [i | i <- [3..],
|
primes = 2 : [i | i <- [3..],
|
||||||
and [rem i p > 0 | p <- takeWhile (\p -> p^2 <= i) primes]]
|
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)
|
primeFactors n = filter (\a -> mod n a == 0) (takeWhile (\m -> m * m < n) primes)
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
print (last (primeFactors 600851475143))
|
print (last (primeFactors 600851475143))
|
||||||
|
|
Loading…
Reference in New Issue