Prerequisite : BigInteger Basics
The probablePrime() method will return a Biginteger of bitLength bits which is prime. bitLength is provided as parameter to method probablePrime() and method will return a prime BigInteger of bitLength bits. The probability that a BigInteger returned by this method is composite and does not exceed 2^-100.
public static BigInteger probablePrime(int bitLength, Random rnd)
Parameters: This method accepts two parameters as shown in the above syntax and described below.
- bitLength – bitLength of the returned BigInteger.
- rnd – source of random bits used to select candidates to be tested for primality.
Return Value: This method returns a BigInteger of bitLength bits that is probably prime.
- ArithmeticException – if bitLength < 2.
Below program illustrate the probablePrime() method:
ProbablePrime whose bit length is 4 = 13
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Java lang.Long.byteValue() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.builtcount() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java 8 | ArrayDeque removeIf() method in Java with Examples
- Java.lang.string.replace() method in Java
- Java.util.ArrayList.addall() method in Java
- Java Clock tickMinutes() method in Java with Examples
- Java.math.BigInteger.modInverse() method in Java
- Java.util.ArrayList.add() Method in Java
- Java.util.BitSet.set() method in Java
- Method Class | toGenericString() method in Java
- Method Class | getGenericParameterTypes() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.