Created
May 24, 2012 18:47
-
-
Save yanks/2783433 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
def is_prime(num) | |
factor = 2 | |
max = num/2 | |
while factor <= max | |
if( num%factor == 0 ) then | |
return false | |
end | |
factor+=1 | |
end | |
return true | |
end | |
def factors(num) | |
factor = 2 | |
max = num/2 | |
while factor <= max | |
if( num%factor == 0 ) then | |
candidate = num/factor | |
puts "CANDIDATE: #{candidate}" | |
if is_prime(candidate) then | |
puts "WIN: #{candidate}" | |
end | |
end | |
factor+=1 | |
end | |
end | |
numbers = factors(600851475143) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment