public final class BigPrimes extends Object
Modifier and Type | Method and Description |
---|---|
static BigInteger |
fermat(BigInteger n,
long upperBound)
Fermat's factoring algorithm works like trial division, but walks in the opposite direction.
|
static boolean |
isPrime(BigInteger n)
Strong primality test.
|
static boolean |
isPrime(long n)
Strong primality test.
|
static boolean |
LucasPrimalityTest(BigInteger n,
int k,
org.apache.commons.math3.random.RandomGenerator rnd) |
static BigInteger |
nextPrime(BigInteger n)
Return the smallest prime greater than or equal to n.
|
static long |
nextPrime(long n)
Return the smallest prime greater than or equal to n.
|
static BigInteger |
PollardP1(BigInteger n,
long upperBound)
Pollards's p-1 algorithm.
|
static BigInteger |
PollardRho(BigInteger n,
int attempts,
org.apache.commons.math3.random.RandomGenerator rn)
Pollards's rho algorithm (random search version).
|
static BigInteger |
PollardRho(BigInteger n,
long upperBound)
Pollards's rho algorithm.
|
static List<BigInteger> |
primeFactors(BigInteger num)
Prime factors decomposition.
|
static long[] |
primeFactors(long num)
Prime factors decomposition.
|
static BigInteger |
QuadraticSieve(BigInteger n,
int bound) |
public static boolean isPrime(long n)
n
- number to testtrue
if input is certainly prime, false
is certainly compositepublic static boolean isPrime(BigInteger n)
n
- number to testtrue
if input is certainly prime, false
is certainly compositepublic static boolean LucasPrimalityTest(BigInteger n, int k, org.apache.commons.math3.random.RandomGenerator rnd)
public static BigInteger nextPrime(BigInteger n)
n
- a positive number.IllegalArgumentException
- if n < 0.public static long nextPrime(long n)
n
- a positive number.IllegalArgumentException
- if n < 0.public static BigInteger fermat(BigInteger n, long upperBound)
n
- number to factorupperBound
- upper boundpublic static BigInteger PollardRho(BigInteger n, int attempts, org.apache.commons.math3.random.RandomGenerator rn)
n
- integer to factorattempts
- number of random attemptsn
or null if no factors foundpublic static BigInteger PollardRho(BigInteger n, long upperBound)
n
- integer to factorupperBound
- expected B-smoothnessn
or null if no factors foundpublic static BigInteger PollardP1(BigInteger n, long upperBound)
n
- integer to factorupperBound
- expected B-smoothnessn
or null if no factors foundpublic static BigInteger QuadraticSieve(BigInteger n, int bound)
public static long[] primeFactors(long num)
num
- number to factorizeIllegalArgumentException
- if n is negativepublic static List<BigInteger> primeFactors(BigInteger num)
num
- number to factorizeIllegalArgumentException
- if n is negativeCopyright © 2017. All rights reserved.