Java BigInteger isProbablePrime() MethodThe isProbablePrime() method of Java BigInteger class is used to determine if the given number is prime or not. For certainty =1, this method returns true if this BigInteger is prime and false if this BigInteger is composite. Syntax:Parameter:certainty - A measure of the uncertainty that the caller is willing to tolerate: if the call returns true the probability that this BigInteger is prime exceeds (1 - 1/2certainty). The execution time of this method is proportional to the value of this parameter. Returns:This method returns true if this BigInteger is probably prime, false if it's definitely composite. Exception:NA Note: If certainty is ≤ 0, this method returns true.Example 1Test it NowOutput: 5 is prime with certainty 1 is true 5 is prime with certainty 0 is true 5 is prime with certainty -1 is true Example 2Test it NowOutput: 8 is prime with certainty 1 is false 8 is prime with certainty 0 is true 8 is prime with certainty -1 is true Example 3Test it NowOutput: 9 is prime with certainty 1 is false 9 is prime with certainty 0 is true 9 is prime with certainty -1 is true Next TopicJava BigInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India