probab_prime#

Probabilistic primality test: return 0, 1, or 2.

Synopsis#

my $x = Math::GMP->new(7);
my $v = $x->probab_prime(10);   # 2 — definitely prime

What you get back#

  • 0 — definitely composite.

  • 1 — probably prime (no witness found in $reps rounds).

  • 2 — definitely prime (small numbers, or libgmp proved it).

$reps is the Miller-Rabin round count; higher values cost more but tighten the confidence on a 1 answer. A round count of 25 is a common default for cryptographic work.