Sha256: f27f1f574e728617a7950a4514e01455a34759785ae25ff0c2ccfca841d38c78
Contents?: true
Size: 431 Bytes
Versions: 396
Compression:
Stored size: 431 Bytes
Contents
module PrimeFactors (primeFactors) where primes :: [Integer] primes = 2 : filter ((==1) . length . primeFactors) [3,5..] primeFactors :: Integer -> [Integer] primeFactors start | start < 2 = [] | otherwise = factor start primes where factor n (p:ps) | p*p > n = [n] | n `mod` p == 0 = p : factor (n `div` p) (p:ps) | otherwise = factor n ps factor _ _ = undefined
Version data entries
396 entries across 396 versions & 1 rubygems