Created
April 1, 2019 06:42
-
-
Save anwinged/c81521855af62259c48fb3a9070b91a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flat_prime_factors :: Integral n => n -> [n] | |
flat_prime_factors n = | |
case factors of | |
[] -> [n] | |
_ -> factors ++ flat_prime_factors (n `div` (head factors)) | |
where | |
factors = take 1 $ filter fcb [2 .. int_sqrt n] | |
fcb x = n `mod` x == 0 | |
int_sqrt = floor . sqrt . fromIntegral |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment