BigInteger.isProbablePrime

For a large known prime b, and for any certainty, b.isProbablePrime(certainty) returns true.

isProbablePrime can only err by returning true when the input is not prime (an example is b=6, certainty=0, which returns true), never the other way (because the Rabin-Miller test, which isProbablePrime uses, can only fail in this direction).


For a large known prime, and for any certainty > 0, is it accurate to say that b.isProbablePrime(certainty) will always return true?

Yes. The documentation says it will return false only if it is certain that the number is composite.

Returns: true if this BigInteger is probably prime, false if it's definitely composite.

So the certainty parameter will influence only on the chance of a false-positive: saying a composite number is prime, when it really is not.

Tags:

Java