Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4814775

java.math.BigInteger.isProbablePrime(int) fails on 2^521-1 (M521)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000



      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)
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: