Created
October 20, 2015 15:41
-
-
Save jonathanpike/befb9714cb431700443a to your computer and use it in GitHub Desktop.
This file contains 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
# With help from: http://math.stackexchange.com/questions/389675/largest-prime-factor-of-600851475143 | |
def largest_prime_factor(number) | |
divisor = 2 | |
largest_divisor = 0 | |
until number == 1 | |
if number % divisor == 0 | |
number /= divisor | |
largest_divisor = divisor | |
else | |
divisor += 1 | |
end | |
end | |
largest_divisor | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment