public class Prime
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
protected static java.math.BigInteger |
nMax |
The maximum integer covered by the high end of the list.
|
| Constructor | Description |
|---|---|
Prime() |
Default constructor initializing a list of primes up to 17.
|
| Modifier and Type | Method | Description |
|---|---|---|
java.math.BigInteger |
at(int i) |
return the ithprime
|
boolean |
contains(java.math.BigInteger n) |
Test if a number is a prime.
|
protected void |
growto(java.math.BigInteger n) |
extend the list of known primes up to n
|
boolean |
isSPP(java.math.BigInteger n,
java.math.BigInteger a) |
Test whether a number n is a strong pseudoprime to base a.
|
static void |
main(java.lang.String[] args) |
Test program.
|
int |
millerRabin(java.math.BigInteger n) |
Miller-Rabin primality tests.
|
java.math.BigInteger |
nextprime(java.math.BigInteger n) |
return the smallest prime larger than n
|
java.math.BigInteger |
pi(java.math.BigInteger n) |
return the count of primes <= n
|
java.math.BigInteger |
prevprime(java.math.BigInteger n) |
return the largest prime smaller than n
|
protected static java.math.BigInteger nMax
public Prime()
public boolean contains(java.math.BigInteger n)
n - the integer to be tested for primalitypublic boolean isSPP(java.math.BigInteger n,
java.math.BigInteger a)
n - the integer to be tested for primalitya - the basepublic int millerRabin(java.math.BigInteger n)
n - The prime candidatepublic java.math.BigInteger at(int i)
i - the zero-based index into the list of primespublic java.math.BigInteger pi(java.math.BigInteger n)
n - the upper limit of the scanpublic java.math.BigInteger nextprime(java.math.BigInteger n)
n - lower limit of the searchpublic java.math.BigInteger prevprime(java.math.BigInteger n)
n - upper limit of the searchprotected void growto(java.math.BigInteger n)
n - the maximum integer known to be prime or not prime after the call.public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception