up previous next
PrevPrime, PrevProbPrime

find the previous prime number

Syntax
PrevPrime(N: INT): INT
PrevProbPrime(N: INT): INT

Description
The first function computes the largest prime number smaller than N . If N is negative or 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 largest 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.

Example
/**/  PrevPrime(1000);
997
/**/  PrevProbPrime(10^50);
99999999999999999999999999999999999999999999999943

See Also