Skip to content

Instantly share code, notes, and snippets.

@nemesit
Last active December 16, 2015 05:19
Show Gist options
  • Save nemesit/5383835 to your computer and use it in GitHub Desktop.
Save nemesit/5383835 to your computer and use it in GitHub Desktop.
ruby Discover if a number is prime http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ Source Article
class Fixnum
def prime?
('1' * self) !~ /^1?$|^(11+?)\1+$/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment