Skip to content

Instantly share code, notes, and snippets.

@photomattmills
Created November 27, 2010 18:07
Show Gist options
  • Save photomattmills/718126 to your computer and use it in GitHub Desktop.
Save photomattmills/718126 to your computer and use it in GitHub Desktop.
class for testing primes.
class PrimeNumber
def self.is_prime(n)
(2..Math.sqrt(n).to_i).each { |test| return false if n.modulo(test) == 0 }
return true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment