Skip to content

Instantly share code, notes, and snippets.

@chendo
Created February 19, 2012 02:04
Show Gist options
  • Save chendo/1861604 to your computer and use it in GitHub Desktop.
Save chendo/1861604 to your computer and use it in GitHub Desktop.
def is_prime?(number)
return false if number == 2
return false if (number % 2).zero?
i = 3
while i * i < number
return false if (number % i).zero?
i += 2
end
true
end
time = Time.now.to_i
time += 1 if (time % 2).zero?
while true
if is_prime?(time)
puts "#{time} #{Time.at(time)} is a prime unixtime"
end
time += 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment