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

Version Path
trackler-2.2.1.139 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.138 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.137 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.136 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.135 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.134 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.133 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.132 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.131 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.130 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.129 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.128 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.127 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.126 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.125 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.124 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.123 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.122 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.121 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.120 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs