gmp :: BigInt :: probab_prime
self
is a prime number.Return 2 if self
is prime, return 1 if self
is probably prime and
return 0 if self
is definitely not a prime number.
This function begins by trying some divisions with small number to find if
there is other factors then self
and one. After that, it uses the
Miller-Rabin probabilistic primality tests. The probability of a non-prime
being identified as probably prime with that test is less than
4^(-reps)
. It is recommended to use a reps
value between 15 and 50.
assert((0x10001).to_bi.probab_prime(15) == 2)
# Determine if `self` is a prime number.
# Return 2 if `self` is prime, return 1 if `self` is probably prime and
# return 0 if `self` is definitely not a prime number.
#
# This function begins by trying some divisions with small number to find if
# there is other factors then `self` and one. After that, it uses the
# Miller-Rabin probabilistic primality tests. The probability of a non-prime
# being identified as probably prime with that test is less than
# `4^(-reps)`. It is recommended to use a `reps` value between 15 and 50.
#
# assert((0x10001).to_bi.probab_prime(15) == 2)
fun probab_prime(reps: Int): Int do
return val.probab_prime_p(reps.to_i32)
end
lib/gmp/gmp.nit:229,5--242,7