Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Forked from atnan/prime.rb
Created November 19, 2009 00:39
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 juliocesar/238422 to your computer and use it in GitHub Desktop.
Save juliocesar/238422 to your computer and use it in GitHub Desktop.
class Integer
def prime?
!("1" * self).match(/^1?$|^(11+?)\1+$/).nil?
end
end
class DHHException < Exception; end
raise DHHException, 'Whoops!' if !1.prime?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment