lib/primes_table/core_ext/integer.rb
def next_prime
    n = self + 1
    n = n + 1 until n.is_prime?
    n
  end
#Returns true if number is prime (false otherwise) using a slightly optimized version of the Trial division method.
#Trial division method: This routine consists of dividing n by each integer m that is greater than 1 and less than
# or equal to the square root of n. If the result of any of these divisions is an integer, then n is not a prime,
# otherwise it is a prime.
# This is OK for small numbers but not for bigger ones!
Returns true if number is prime (false otherwise) using a slightly optimized version of the Trial division method.
Trial division method: This routine consists of dividing n by each integer m that is greater than 1 and less than
or equal to the square root of n. If the result of any of these divisions is an integer, then n is not a prime,
otherwise it is a prime.
This is OK for small numbers but not for bigger ones!
Returns true if number is prime ( false otherwise ) using a slightly optimized version of the Trial division method . Trial division method : This routine consists of dividing n by each integer m that is greater than 1 and less than or equal to the square root of n . If the result of any of these divisions is an integer then n is not a prime otherwise it is a prime . This is OK for small numbers but not for bigger ones!
def next_prime
    n = self + 1
    n = n + 1 until n.is_prime?
    n
  end
def next_prime n = self + 1 n = n + 1 until n . is_prime? n end
Returns true if number is prime (false otherwise) using a slightly optimized version of the Trial division method.
Returns true if number is prime ( false otherwise ) using a slightly optimized version of the Trial division method .