Skip to content

Instantly share code, notes, and snippets.

@Manume
Created June 4, 2014 06:33
Show Gist options
  • Save Manume/4a2024fbbde76372ae8a to your computer and use it in GitHub Desktop.
Save Manume/4a2024fbbde76372ae8a to your computer and use it in GitHub Desktop.
Ruby program to find largest prime factor
#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