Created
October 4, 2012 06:30
-
-
Save rvbsanjose/3831784 to your computer and use it in GitHub Desktop.
Prime factors
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 primes(input) | |
primes = [] | |
number = 2 | |
(number..input).each do | |
if input % number == 0 | |
primes << number | |
input /= number | |
else | |
number += 1 | |
end | |
end | |
primes | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment