Created
October 19, 2012 00:06
-
-
Save kareemgrant/3915511 to your computer and use it in GitHub Desktop.
Script that prints the 10,001st prime number
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
require 'mathn' | |
prime_array = [] | |
TARGET = 10001 | |
Prime.each do |prime| | |
if prime_array.size < TARGET | |
prime_array.push(prime) | |
else | |
break | |
end | |
end | |
puts "The 10,001st Prime Number is #{prime_array.last}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment