Created
June 4, 2014 05:08
-
-
Save Manume/3b155ea48121228ff7da 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
#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