Skip to content

Instantly share code, notes, and snippets.

@tamurashingo
Created December 6, 2012 23:09
Show Gist options
  • Save tamurashingo/4229315 to your computer and use it in GitHub Desktop.
Save tamurashingo/4229315 to your computer and use it in GitHub Desktop.
factor :: Integer -> [Integer]
factor n = factor_iter n 2 []
factor_iter :: Integer -> Integer -> [Integer] -> [Integer]
factor_iter n x xs | n < x = reverse xs
| n `mod` x == 0 = factor_iter (n `div` x) x (x:xs)
| otherwise = factor_iter n (x + 1) xs
main = print (maximum((factor 600851475143)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment