Last active
August 29, 2015 14:10
-
-
Save thehungrycoder/39cfb20e816279f6e0a6 to your computer and use it in GitHub Desktop.
333rd prime
This file contains hidden or 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
#!/usr/bin/ruby | |
require 'prime' | |
# This is a quick & simple script to find 333rd of all prime numbers begins & ends with 3. | |
numOfPrime = 0 | |
i = 0 | |
while true do | |
i += 1 | |
if !Prime.prime?(i) | |
next | |
end | |
if i.to_s.split('').first == '3' and i.to_s.split('').last == '3' | |
puts i | |
numOfPrime += 1 | |
end | |
if numOfPrime == 333 | |
puts "333rd prime of number beginning and ending with 3 is %d " % i; | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment