up previous next
NextPrime, NextProbPrime    --    find the next prime number


Syntax
NextPrime(N: INT): INT
NextProbPrime(N: INT): INT

Description
The first function computes the smallest prime number greater than N. If N is too large then an error is signalled. The upper limit depends on the computer you are using; it is probably 2^31 or 2^63.

The second function computes the smallest probable prime number greater than N. To be absolutely certain the number produced is prime, you must call IsPrime on it, but this may be very costly.

The functions give errors if handed negative arguments. NextProbPrime uses IsProbPrime which cannot be interrupted, so be wary of inputs larger than about 2^100000 (which already takes a few minutes).

Example
/**/  NextPrime(1000);
1009
/**/ NextProbPrime(10^50);
100000000000000000000000000000000000000000000000151

See Also