blob: 185d024e4b5d11bbced9376bec7eca93d8023736 (
plain) (
tree)
|
|
primeFactors :: Int -> [Int]
primeFactors x = factor x primes
where primes = filterPrime [2..]
filterPrime (p:xs) = p:filterPrime [x | x <- xs, x `mod` p /= 0]
factor x l@(p:xs)
| p > x = []
| x `mod` p == 0 = p:factor (x `div` p) l
| otherwise = factor x xs
|