NextPrime

NextPrime[x]

gives the smallest prime above x.

NextPrime[x,k]

gives the k^(th)-next prime above x.

Details

  • When used with a negative k value, NextPrime will give the previous k^(th)prime.
  • Mathematical function, suitable for both symbolic and numerical manipulation.
  • For positive x, NextPrime[x] is the (m+1)^(th) prime number where m is the number of primes less than or equal to x.
  • NextPrime[x, k] is the (m+k)^(th) prime number where m is the number of primes less than or equal to x.

Examples

open allclose all

Basic Examples  (2)

Compute the next prime after 10:

Plot the sequence of primes:

Scope  (9)

Numerical Evaluation  (7)

NextPrime works over integers:

Rational numbers:

Real numbers:

Compute the last prime before 50:

Compute the second prime after 50:

NextPrime works over large integers:

NextPrime threads over lists:

Symbolic Manipulation  (2)

Find a solution instance of equalities with NextPrime:

Reduce an equation:

Applications  (15)

Basic Applications  (6)

Highlight the sequence of primes using NextPrime:

Visualize the primes with a parabolic sieve:

Visualize the sieve of Eratosthenes for the first 5 primes:

Spiral of a NextPrime sequence:

Hexagonal prime spiral using NextPrime:

Find the lowest-divisor pair for an integer :

Find the prime factorization for an integer :

Construct a factorization tree for an integer :

Approximations  (2)

Approximation to Prime:

Plot Prime compared with an estimate:

Compute Prime:

Number Theory  (5)

NextPrime numbers modulo 10:

NextPrime numbers modulo :

Plot prime gaps around powers of 10:

Visualize the gaps between primes below 104:

Plot a histogram of the closest distances to a prime for a range of integers:

Compare the NextPrime sequence to PrimePi:

It is conjectured that for any integer , there is a prime with :

Verify this for a range of integers:

Special Sequences  (2)

Find twin primes, i.e. pairs of primes of the form :

Plot the twin primes:

Compute the smallest n-digit prime:

Plot the difference between the smallest n-digit prime and :

Properties & Relations  (4)

Primes represents the domain of all primes numbers:

The largest domain of definitions of NextPrime:

Compute the prime using NextPrime:

Compute using PrimePi:

Neat Examples  (5)

Ulam spiral of the distance to the next prime:

Generate a path based on the NextPrime sequence:

Visualize the increase in prime numbers through -sided polygons:

Plot NextPrime using ArrayPlot:

Sunflower seed representation of NextPrime:

Wolfram Research (2007), NextPrime, Wolfram Language function, https://reference.wolfram.com/language/ref/NextPrime.html (updated 2020).

Text

Wolfram Research (2007), NextPrime, Wolfram Language function, https://reference.wolfram.com/language/ref/NextPrime.html (updated 2020).

CMS

Wolfram Language. 2007. "NextPrime." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/NextPrime.html.

APA

Wolfram Language. (2007). NextPrime. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NextPrime.html

BibTeX

@misc{reference.wolfram_2024_nextprime, author="Wolfram Research", title="{NextPrime}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/NextPrime.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_nextprime, organization={Wolfram Research}, title={NextPrime}, year={2020}, url={https://reference.wolfram.com/language/ref/NextPrime.html}, note=[Accessed: 21-November-2024 ]}