Generate random probable prime guaranteed to be greater than the number specified.

@param num lower bound for the generated probable prime
@return random probable prime greater than the specified number
324820
public static BigInteger generateRandomPrimeGreaterThan(BigInteger num) {
        BigInteger res = BigInteger.ZERO;
        while (res.compareTo(num) <= 0) {
            res = BigInteger.probablePrime(num.bitLength(), RANDOM);
        }
        return res;
    }
1159649
public static int findNextPrime(int number) {
        // 2 is the smallest positive prime number.
        if (number <= 2)
            return 2;

        // Even numbers (other than 2) are not prime.
        if (isEven(number))
            ++number;

        if (number > MAX_PRIME_INTEGER)
            return number;

        // For safety, don't loop forever looking for a prime, and skip
        // all of the evens, as they are not prime (except 2).
        for (int next = number; next < number + 1000; next += 2) {
            if (isPrime(next))
                return next;
        }

        return number;
    }
1300159
public static int randomIntLessThan(int maxExclusive) {
    checkArgument(
        maxExclusive > Integer.MIN_VALUE, "Cannot produce int less than %s", Integer.MIN_VALUE);
    return randomInt(Integer.MIN_VALUE, maxExclusive);
  }
1017478
static int randomNumber(int minimum, int maximum) {
        assert minimum < maximum;
        double fraction = PlatformDependent.threadLocalRandom().nextDouble();

        // the idea here is that nextDouble gives us a random value
        //
        //              0 <= fraction <= 1
        //
        // the distance from min to max declared as
        //
        //              dist = max - min
        //
        // satisfies the following
        //
        //              min + dist = max
        //
        // taking into account
        //
        //         0 <= fraction * dist <= dist
        //
        // we've got
        //
        //       min <= min + fraction * dist <= max
        return (int) (minimum + fraction * (maximum - minimum));
    }
1091573
public OptionalSyntax take(int num) {
		getMessage().setMaxresults(num);
		QueryMessage mess = getMessage();
		return new OptionalSyntax(mess);
	}
874986
BigInteger retrieve(BigInteger initValue, int certainty, java.util.Random random) {
        // Examine the sieve one long at a time to find possible primes
        int offset = 1;
        for (int i=0; i<bits.length; i++) {
            long nextLong = ~bits[i];
            for (int j=0; j<64; j++) {
                if ((nextLong & 1) == 1) {
                    BigInteger candidate = initValue.add(
                                           BigInteger.valueOf(offset));
                    if (candidate.primeToCertainty(certainty, random))
                        return candidate;
                }
                nextLong >>>= 1;
                offset+=2;
            }
        }
        return null;
    }
453403
def randbelow(num: int) -> int:
    
    if not isinstance(num, int):
        raise TypeError('number must be an integer')
    if num <= 0:
        raise ValueError('number must be greater than zero')
    if num == 1:
        return 0

    # https://github.com/python/cpython/blob/3.6/Lib/random.py#L223
    nbits = num.bit_length()    # don't use (n-1) here because n can be 1
    randnum = random_randint(nbits)    # 0 <= randnum < 2**nbits
    while randnum >= num:
        randnum = random_randint(nbits)
    return randnum
109886
def uniform_int(low:int, high:int, size:Optional[List[int]]=None)->IntOrTensor:
    ""
    return random.randint(low,high) if size is None else torch.randint(low,high+1,size)
178884
def random(self, max_number=None):
        
        min_number = self.obj
        if max_number is None:
            min_number = 0
            max_number = self.obj
        return random.randrange(min_number, max_number)
915767
def uniform(low, high, random_state):
    '''
    
    '''
    assert high > low, 'Upper bound must be larger than lower bound'
    return random_state.uniform(low, high)
588145
public static double random(double min, double max) {
        assert max > min;
        return min + Math.random() * (max - min);
    }
394517
public static double uniform(Random rng, double min, double max) {
        return rng.nextDouble() * (max - min) + min;
    }
1265949
def randint(self, low: int, high: int) -> int:
        
        return int(lib.TCOD_random_get_i(self.random_c, low, high))
150935
public static int binomial(RandomGenerator rng, int n, double p) {
        if ((p < 0) || (p > 1)) {
            return 0;
        }
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (rng.nextDouble() < p) {
                c++;
            }
        }
        return c;
    }
372767
def _generate_prime(bits, rng):
    ""
    hbyte_mask = pow(2, bits % 8) - 1
    while True:
        # loop catches the case where we increment n into a higher bit-range
        x = rng.read((bits+7) // 8)
        if hbyte_mask > 0:
            x = chr(ord(x[0]) & hbyte_mask) + x[1:]
        n = util.inflate_long(x, 1)
        n |= 1
        n |= (1 << (bits - 1))
        while not number.isPrime(n):
            n += 2
        if util.bit_length(n) == bits:
            break
    return n
205468
private BigInteger coeffGenImproved(Random random, BigInteger modulus)
    {
        BigInteger big;
        int bitLength;
        if (modulus != null)
        {
            bitLength = modulus.bitLength();
        }
        else
        {
            bitLength = 4096;
        }
        // TODO: safety bit?
        bitLength = bitLength - 1;
        big = new BigInteger(bitLength, random);
        return big;

    }
8944
public static NumberExpression<Double> random(int seed) {
        return Expressions.numberOperation(Double.class, MathOps.RANDOM2, ConstantImpl.create(seed));
    }