determine the next largest prime - Maple Help

Home : Support : Online Help : Mathematics : Group Theory : Numbers : Prime : nextprime

nextprime - determine the next largest prime

prevprime - determine the next smallest prime

 Calling Sequence nextprime(n) prevprime(n)

Parameters

 n - integer

Description

 • The nextprime function returns the smallest prime that is larger than n. The prevprime function returns the largest prime that is less than n.

Examples

 > $\mathrm{nextprime}\left(1\right)$
 ${2}$ (1)
 > $\mathrm{nextprime}\left(0\right)$
 ${2}$ (2)
 > $\mathrm{prevprime}\left(2\right)$
 > $\mathrm{nextprime}\left(25\right)$
 ${29}$ (3)
 > $\mathrm{prevprime}\left(3\right)$
 ${2}$ (4)
 > $\mathrm{prevprime}\left(25\right)$
 ${23}$ (5)
 > $\mathrm{nextprime}\left(31243\right)$
 ${31247}$ (6)
 > $\mathrm{prevprime}\left(2338714\right)$
 ${2338703}$ (7)
 > $\mathrm{nextprime}\left({2}^{6}\right)$
 ${67}$ (8)