Name: gm110360 Date: 02/07/2003
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, STandard Edition (build 1.4.0-b92)
Java Hotspot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows2000 [versie 5.00.2195]
Service Pack 3
A DESCRIPTION OF THE PROBLEM :
The method java.math.BigInteger.isProbablePrime(int) does
not recognize some Mersenne primes, e.g. 2^521-1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the main in MersennePrint class below
2.
3.
EXPECTED VERSUS ACTUAL BEHAVIOR :
It prints the following:
2
3
5
7
13
17
19
31
61
89
107
127
607
So it is missing 521.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.math.BigInteger;
public class MersennePrint {
public MersennePrint() {
}
public static void main(String[] args) {
// try to get the Mersenne primes
for (int i = 2; i < 610; i++) {
BigInteger bi =
BigInteger.ONE.shiftLeft(i).subtract(BigInteger.ONE);
if (bi.isProbablePrime(10)) {
System.out.println(i);
}
}
}
}
---------- END SOURCE ----------
(Review ID: 180967)
======================================================================
- duplicates
-
JDK-4624738 BigInteger.isProbablePrime() reports certain primes as composite
-
- Closed
-