本文整理了Java中java.math.BigInteger.nextProbablePrime()
方法的一些代码示例,展示了BigInteger.nextProbablePrime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigInteger.nextProbablePrime()
方法的具体详情如下:
包路径:java.math.BigInteger
类名称:BigInteger
方法名:nextProbablePrime
[英]Returns the smallest integer x > this which is probably prime as a BigInteger instance. The probability that the returned BigInteger is prime is greater than 1 - 1/2100.
[中]
代码示例来源:origin: DataSketches/sketches-core
/**
* Returns the next prime number that is greater than the given target. There will be
* no prime numbers less than the returned prime number that are greater than the given target.
* @param target the starting value to begin the search for the next prime
* @return the next prime number that is greater than the given target.
*/
static int nextPrime(final int target) {
return BigInteger.valueOf(target).nextProbablePrime().intValueExact();
}
代码示例来源:origin: com.googlecode.totallylazy/totallylazy
@Override
public BigInteger call(BigInteger bigInteger) throws Exception {
return bigInteger.nextProbablePrime();
}
};
代码示例来源:origin: stackoverflow.com
public BigInteger randomPrime(int bits, Random random) {
return new BigInteger(bits, random).nextProbablePrime();
// or
// return BigInteger.probablePrime(bits, random);
}
代码示例来源:origin: stackoverflow.com
BigInteger big = new BigInteger("9001");//or whatever big number you want to start with
BigInteger[] primes = new BigInteger[10];
for(int i=0;i<10;i++){
primes[i]=big=big.nextProbablePrime();
}
代码示例来源:origin: stackoverflow.com
create schema PERMISSION_TOOLS;
CREATE ALIAS PERMISSION_TOOLS.GET_ACCESS_LEVEL as $$
String nextPrime(String value) {
return new BigInteger(value).nextProbablePrime().toString();
}
$$;
select permission_tools.get_access_level(1) from dual;
代码示例来源:origin: com.madgag.spongycastle/core
public BigInteger nextPrime()
{
if (index < BIGINT_PRIMES.size())
{
prime = (BigInteger)BIGINT_PRIMES.get(index++);
}
else
{
prime = prime.nextProbablePrime();
}
return prime;
}
}
代码示例来源:origin: stackoverflow.com
BigInteger prime = BigInteger.valueOf(0);
for (int i = 0; i < n; i++) {
prime = prime.nextProbablePrime();
}
System.out.println(prime.intValue());
代码示例来源:origin: stackoverflow.com
BigInteger veryBig = new BigInteger(10000, new Random());
veryBig.nextProbablePrime();
代码示例来源:origin: stackoverflow.com
BigInteger.valueOf((int)(numOfEntries / 0.65)).nextProbablePrime().intValue()
代码示例来源:origin: stackoverflow.com
BigInteger n = new BigInteger(stringInputN);
BigInteger test = BigInteger.valueOf(2);
BigInteger total = BigInteger.valueOf(0);
while (test.compareTo(n) < 0){
total = total.add(test);
test = test.nextProbablePrime();
}
System.out.println(total);
代码示例来源:origin: stackoverflow.com
class PrimeProducer extends Thread {
private final BlockingQueue<BigInteger> queue;
PrimeProducer(BlockingQueue<BigInteger> queue) {
this.queue = queue;
}
public void run() {
try {
BigInteger p = BigInteger.ONE;
while (!Thread.currentThread().isInterrupted())
queue.put(p = p.nextProbablePrime());
} catch (InterruptedException consumed) {
/* Allow thread to exit */
}
}
public void cancel() { interrupt(); }
}
代码示例来源:origin: stackoverflow.com
public class PrimeProducer extends Thread {
private final BlockingQueue<BigInteger> queue;
PrimeProducer(BlockingQueue<BigInteger> queue) {
this.queue = queue;
}
public void run() {
try {
BigInteger p = BigInteger.ONE;
while (!Thread.currentThread().isInterrupted())
queue.put(p = p.nextProbablePrime());
} catch (InterruptedException consumed) {
/* Allow thread to exit */
}
}
public void cancel() { interrupt(); }}
代码示例来源:origin: stackoverflow.com
class PrimeProducer extends Thread {
private final BlockingQueue<BigInteger> queue;
PrimeProducer(BlockingQueue<BigInteger> queue) {
this.queue = queue;
}
public void run() {
try {
BigInteger p = BigInteger.ONE;
while (!Thread.currentThread().isInterrupted())
queue.put(p = p.nextProbablePrime());
} catch (InterruptedException consumed) {
/* Allow thread to exit */
}
}
public void cancel() { interrupt(); }
}
代码示例来源:origin: stackoverflow.com
public class PrimeProducer extends Thread {
private final BlockingQueue<BigInteger> queue;
PrimeProducer(BlockingQueue<BigInteger> queue) {
this.queue = queue;
}
public void run() {
try {
BigInteger p = BigInteger.ONE;
while (!Thread.currentThread().isInterrupted())
queue.put(p = p.nextProbablePrime());
} catch (InterruptedException consumed) {
/* Allow thread to exit */
}
}
public void cancel() { interrupt(); }
}
代码示例来源:origin: org.apache.nemo/nemo-runtime-executor
/**
* Constructor.
*
* @param hashRangeMultiplier the hash range multiplier.
* @param dstParallelism the number of destination tasks.
* @param keyExtractor the key extractor that extracts keys from elements.
*/
public DataSkewHashPartitioner(final int hashRangeMultiplier,
final int dstParallelism,
final KeyExtractor keyExtractor) {
this.keyExtractor = keyExtractor;
// For this hash range, please check the description of HashRangeMultiplier in JobConf.
// For actual hash range to use, we calculate a prime number right next to the desired hash range.
this.hashRangeBase = new BigInteger(String.valueOf(dstParallelism * hashRangeMultiplier));
this.hashRange = hashRangeBase.nextProbablePrime().intValue();
LOG.info("hashRangeBase {} resulting hashRange {}", hashRangeBase, hashRange);
}
代码示例来源:origin: com.yahoo.datasketches/sketches-core
/**
* Returns the next prime number that is greater than the given target. There will be
* no prime numbers less than the returned prime number that are greater than the given target.
* @param target the starting value to begin the search for the next prime
* @return the next prime number that is greater than the given target.
*/
static int nextPrime(final int target) {
return BigInteger.valueOf(target).nextProbablePrime().intValueExact();
}
代码示例来源:origin: cc.redberry/core
/**
* get prime at index i.
*/
public java.math.BigInteger get(int i) {
java.math.BigInteger p;
if (i < size()) {
p = val.get(i);
} else {
p = last.nextProbablePrime();
val.add(p);
last = p;
}
return p;
}
代码示例来源:origin: org.appdapter/ext.bundle.math.symja_jas
/**
* get prime at index i.
*/
public java.math.BigInteger get(int i) {
java.math.BigInteger p;
if (i < size()) {
p = val.get(i);
} else {
p = last.nextProbablePrime();
val.add(p);
last = p;
}
return p;
}
代码示例来源:origin: axkr/symja_android_library
@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
Validate.checkRange(ast, 2, 3);
if (ast.isAST1() && ast.arg1().isInteger()) {
BigInteger primeBase = ((IInteger) ast.arg1()).toBigNumerator();
return F.integer(primeBase.nextProbablePrime());
} else if (ast.isAST2() && ast.arg1().isInteger() && ast.arg2().isInteger()) {
BigInteger primeBase = ((IInteger) ast.arg1()).toBigNumerator();
final int n = Validate.checkIntType(ast, 2, 1);
BigInteger temp = primeBase;
for (int i = 0; i < n; i++) {
temp = temp.nextProbablePrime();
}
return F.integer(temp);
}
return F.NIL;
}
代码示例来源:origin: org.appdapter/ext.bundle.math.symja_jas
@Override
public IExpr evaluate(final IAST ast) {
Validate.checkRange(ast, 2, 3);
if (ast.size() == 2 && ast.get(1).isInteger()) {
BigInteger primeBase = ((IntegerSym) ast.get(1)).getBigNumerator();
return F.integer(primeBase.nextProbablePrime());
} else if (ast.size() == 3 && ast.get(1).isInteger() && ast.get(2).isInteger()) {
BigInteger primeBase = ((IntegerSym) ast.get(1)).getBigNumerator();
final int n = Validate.checkIntType(ast, 2, 1);
BigInteger temp = primeBase;
for (int i = 0; i < n; i++) {
temp = temp.nextProbablePrime();
}
return F.integer(temp);
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!