Created
October 31, 2011 03:45
-
-
Save notyy/1326865 to your computer and use it in GitHub Desktop.
super fast
This file contains hidden or 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
getPrime :: Integer -> Integer | |
getPrime n = head $! filter (\x -> n `mod` x == 0) ([2..(sqrtIntn (realToFrac n))] ++ [n]) | |
where sqrtIntn n = ceiling (sqrt n) | |
primeList :: Integer -> [Integer] | |
primeList n | prime == n = [n] | |
| otherwise = prime : primeList (n `div` prime) | |
where prime = getPrime n | |
problem3 n = last $ primeList n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment