Skip to content

Instantly share code, notes, and snippets.

@thehungrycoder
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehungrycoder/39cfb20e816279f6e0a6 to your computer and use it in GitHub Desktop.
Save thehungrycoder/39cfb20e816279f6e0a6 to your computer and use it in GitHub Desktop.
333rd prime
#!/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