Skip to content

Instantly share code, notes, and snippets.

@chrislloyd
Forked from atnan/prime.rb
Created November 19, 2009 00:52
Show Gist options
  • Save chrislloyd/238431 to your computer and use it in GitHub Desktop.
Save chrislloyd/238431 to your computer and use it in GitHub Desktop.
class Integer
def prime?
("1" * self).match(/^1?$|^(11+?)\1+$/).nil?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment