Uploaded image for project: 'Commons Numbers'
  1. Commons Numbers
  2. NUMBERS-133

Speed up Primes.nextPrime(int)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.0
    • None
    • primes
    • None

    Description

      The method Primes.nextPrime(int) can use the same algorithm to skip multiples of certain primes as SmallPrimes.boundedTrialDivision(int, int, List<Integer>) uses, instead of hard-coding the alternating increment of the trial candidate into a loop.

      Also, if the argument of the method is smaller than or equal to the 512th prime number, the method can just infer the next higher prime number directly from the array SmallPrimes.PRIMES without performing any calculations.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Schamschi Heinrich Bohne
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m