Last active
November 28, 2015 05:04
-
-
Save notmarkmiranda/63c565beba058e051fcf to your computer and use it in GitHub Desktop.
Euler - 003.rb
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 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