Created
August 31, 2013 19:33
-
-
Save alex-quiterio/6400137 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
natural_primer = ->(number) { | |
primes = [1] | |
number.times do | |
next_prime = primes.reduce(:*) + 1 | |
primes << next_prime | |
end | |
puts primes[1..-1].join(', ') | |
} | |
unless ARGV[0].nil? | |
natural_primer.(ARGV[0].to_i) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment