Files
eulerfunt/haskell/Lib.hs
Amneesh Singh e3f9ab49f3 haskell: add p3
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-10-27 04:21:00 +05:30

14 lines
380 B
Haskell

module Lib (fib, primeFactors) where
fib :: [Integer]
fib = 1 : 2 : zipWith (+) fib (tail fib)
primeFactors :: Integer -> [Integer]
primeFactors n = genPrimeFactors n 2
where
genPrimeFactors :: Integer -> Integer -> [Integer]
genPrimeFactors n c
| c == n = [n]
| mod n c /= 0 = genPrimeFactors n (c + 1)
| otherwise = c : genPrimeFactors (div n c) c