/** * 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(); }
@Override public BigInteger call(BigInteger bigInteger) throws Exception { return bigInteger.nextProbablePrime(); } };
public BigInteger randomPrime(int bits, Random random) { return new BigInteger(bits, random).nextProbablePrime(); // or // return BigInteger.probablePrime(bits, random); }
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(); }
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;
public BigInteger nextPrime() { if (index < BIGINT_PRIMES.size()) { prime = (BigInteger)BIGINT_PRIMES.get(index++); } else { prime = prime.nextProbablePrime(); } return prime; } }
BigInteger prime = BigInteger.valueOf(0); for (int i = 0; i < n; i++) { prime = prime.nextProbablePrime(); } System.out.println(prime.intValue());
BigInteger veryBig = new BigInteger(10000, new Random()); veryBig.nextProbablePrime();
BigInteger.valueOf((int)(numOfEntries / 0.65)).nextProbablePrime().intValue()
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);
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(); } }
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(); }}
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(); } }
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(); } }
/** * 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); }
/** * 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(); }
/** * 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; }
/** * 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; }
@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; }
@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; }