Is the given number a prime number?

Follow me on Twitter or Github for more info and updates.

How to use

require "is_prime" # => true # => false

What algorithm is being used?

The implementation is just one line.

('1' * N) !~ /^1?$|^(11+?)\1+$/

Read more about it here.

How to install

[sudo] gem install is_prime


is_prime is tested in Mac OS X 10.6.6, 10.6.7 using Ruby 1.8.7, 1.9.2.


is_prime is released under the MIT license.