Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Java BigInteger nextProbablePrime method works?

I'm working with Java BigInteger Class and curious about the Algorithm behind nextProbablePrime method. I know about some efficient primality testing algorithm like Miller-Rabin but not sure about which algorithm was implemented here.

Trying the following code for a good time and still no response.

BigInteger number = BigInteger.ZERO;
number = number.setBit(82589933);
number = number.nextProbablePrime();
like image 785
User_67128 Avatar asked Feb 10 '26 02:02

User_67128


1 Answers

I have gone through with the source code of BigInteger. It is internally using the MillerRabin algorithm for the nextProbablePrime method.

like image 103
Chandra Shekhar Paatni Avatar answered Feb 13 '26 03:02

Chandra Shekhar Paatni