The method BigInteger.isProbablePrime()
is quite strange; from the documentation, this will tell whether a number is prime with a probability of 1 - 1 / 2^arg
, where arg
is the integer argument.
It has been present in the JDK for quite a long time, so it means it must have uses. My limited knowledge in computer science and algorithms (and maths) tells me that it does not really make sense to know whether a number is "probably" a prime but not exactly a prime.
So, what is a possible scenario where one would want to use this method? Cryptography?