nextprime
determine the next largest prime
prevprime
determine the next smallest prime
Calling Sequence
Parameters
Description
Examples
nextprime(n)
prevprime(n)
n
-
integer
The nextprime function returns the smallest prime that is larger than n. The prevprime function returns the largest prime that is less than n.
nextprime1
2
nextprime0
prevprime2
Error, (in prevprime) there are no primes less than 2
nextprime25
29
prevprime3
prevprime25
23
nextprime31243
31247
prevprime2338714
2338703
nextprime26
67
See Also
isprime
ithprime
Nextpoly
Download Help Document