Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- firstSatisfying :: (a -> Bool) -> [a] -> a
- firstSatisfying f l
- | f (head l) == True = head l
- | otherwise = firstSatisfying f (tail l)
- primeFactorisation :: (Integral a) => a -> [a]
- primeFactorisation x
- | x <= 0 = error "Wrong number"
- | x == 1 = []
- | otherwise = [firstDivisor] ++ primeFactorisation (x `div` firstDivisor)
- where
- divisorList = [2..x]
- firstDivisor = firstSatisfying (\y -> x `mod` y == 0) divisorList
- main = putStrLn (show (primeFactorisation (2 * 9 * 7 * 100500)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement