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.180 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.179 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.178 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.177 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.176 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.175 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.174 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.173 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.172 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.171 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.170 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.169 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.167 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.166 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.165 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.164 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.163 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.162 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.161 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs
trackler-2.2.1.160 tracks/haskell/exercises/prime-factors/examples/success-standard/src/PrimeFactors.hs