Skip to content

Instantly share code, notes, and snippets.

@notyy
Created October 31, 2011 03:45
Show Gist options
  • Save notyy/1326865 to your computer and use it in GitHub Desktop.
Save notyy/1326865 to your computer and use it in GitHub Desktop.
super fast
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