euler/haskell/prime.hs

7 lines
207 B
Haskell
Raw Normal View History

2020-10-28 08:30:06 +00:00
module Prime where
primes = 2 : [i | i <- [3..],
and [rem i p > 0 | p <- takeWhile (\p -> p^2 <= i) primes]]
primeFactors n = filter (\a -> mod n a == 0) (takeWhile (\m -> m * m < n) primes)