Skip to content

Instantly share code, notes, and snippets.

@Manume
Created June 4, 2014 05:08
Show Gist options
  • Save Manume/3b155ea48121228ff7da to your computer and use it in GitHub Desktop.
Save Manume/3b155ea48121228ff7da to your computer and use it in GitHub Desktop.
Ruby program to find largest prime factor
#Ruby program for find the prime factor of 600851475143
def gen_prime_factors(num)
result = []
2.upto(num-1) do |i|
result.push i if num % i == 0
puts "Prime factor found: #{i}"
end
result
end
puts gen_prime_factors(600851475143).last
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment