This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

NextPrime

NextPrime[n]
gives the next prime above .
NextPrime
gives the ^(th) prime above .
  • The number can be negative, giving previous primes.
  • The number need not be an integer, and can be negative. »
The next prime after a million:
The last prime before a million:
The next prime after a million:
In[1]:=
Click for copyable input
Out[1]=
 
The last prime before a million:
In[1]:=
Click for copyable input
Out[1]=
NextPrime allows real numbers as arguments:
Arguments can be negative:
A negative second argument gives previous primes:
Plot prime gaps around powers of 10:
Find twin primes:
New in 6