Created
June 4, 2014 06:33
-
-
Save Manume/4a2024fbbde76372ae8a to your computer and use it in GitHub Desktop.
Ruby program to find largest prime factor
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
#To find the biggest frame | |
require 'prime' | |
max = 600851475143; test = 3 | |
while (max >= test) do | |
if (test.prime? && (max % test == 0)) | |
best = test | |
max = max / test | |
else | |
test = test + 2 | |
end | |
end | |
puts "Here's your number: #{best}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment