Is the given number a prime number?
How to use
require "is_prime" 3.prime? # => true 4.prime? # => 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.