NextPrime

NextPrime[n]

gives the next prime above n.

NextPrime[n,k]

gives the k^(th) prime above n.

Details

  • The number k can be negative, giving previous primes.
  • The number n need not be an integer, and can be negative. »

Examples

open allclose all

Basic Examples  (2)

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]=

Scope  (3)

Applications  (2)

Properties & Relations  (1)

See Also

Prime  PrimePi  RandomPrime  PrimeQ

Tutorials

Introduced in 2007
(6.0)