Skip to content

Instantly share code, notes, and snippets.

@yanks
Created May 24, 2012 18:47
Show Gist options
  • Save yanks/2783433 to your computer and use it in GitHub Desktop.
Save yanks/2783433 to your computer and use it in GitHub Desktop.
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