Object
Returns true if self
is a prime number, else returns false.
Not recommended for very big integers (> 10**23).
# File prime.rb, line 35 def prime? return self >= 2 if self <= 3 if (bases = miller_rabin_bases) return miller_rabin_test(bases) end return true if self == 5 return false unless 30.gcd(self) == 1 (7..Integer.sqrt(self)).step(30) do |p| return false if self%(p) == 0 || self%(p+4) == 0 || self%(p+6) == 0 || self%(p+10) == 0 || self%(p+12) == 0 || self%(p+16) == 0 || self%(p+22) == 0 || self%(p+24) == 0 end true end