NextPrime
Details
- When used with a negative k value, NextPrime will give the previous prime.
- Mathematical function, suitable for both symbolic and numerical manipulation.
- For positive x, NextPrime[x] is the (m+1) prime number where m is the number of primes less than or equal to x.
- NextPrime[x, k] is the (m+k) prime number where m is the number of primes less than or equal to x.
Examples
open allclose allScope (9)
Numerical Evaluation (7)
Symbolic Manipulation (2)
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 :
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 :
Properties & Relations (4)
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