Skip to content

Instantly share code, notes, and snippets.

@notmarkmiranda
Last active November 28, 2015 05:04
Show Gist options
  • Save notmarkmiranda/63c565beba058e051fcf to your computer and use it in GitHub Desktop.
Save notmarkmiranda/63c565beba058e051fcf to your computer and use it in GitHub Desktop.
Euler - 003.rb
def isPrime(n)
factors = []
(2..n-1).each do |x|
if (n % x == 0)
return false
end
end
factors << n
puts factors
end
def find_factors(number)
(2..number/2).each do |y|
if (number % y == 0)
isPrime(y)
end
end
end
find_factors(600851475143)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment