Skip to content

Instantly share code, notes, and snippets.

@AlexVPopov
Last active December 20, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexVPopov/6138418 to your computer and use it in GitHub Desktop.
Save AlexVPopov/6138418 to your computer and use it in GitHub Desktop.
Project Euler 3
def FindLargestPrime(n)
return 1 if n == 1
prime_factor = 2
while prime_factor * prime_factor <= n do
if n % prime_factor == 0 then n /= prime_factor
else prime_factor += 1
end
end
n
end
puts FindLargestPrime(600851475143)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment