Skip to content

Instantly share code, notes, and snippets.

@mikamix
Created December 27, 2013 18:35
Show Gist options
  • Select an option

  • Save mikamix/8150850 to your computer and use it in GitHub Desktop.

Select an option

Save mikamix/8150850 to your computer and use it in GitHub Desktop.
primeFactors n = primeFactors' n 2
where
primeFactors' n f
| f ^ 2 > n = [n]
| n `mod` f == 0 = f : primeFactors' (n `div` f) f
| otherwise = primeFactors' n (f + 1)
main = print $ maximum $ primeFactors 600851475143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment