gives the number of primes less than or equal to x.
Details and Options
- PrimePi is also known as prime counting function.
- Mathematical function, suitable for both symbolic and numerical manipulation.
- counts the prime numbers less than or equal to x.
- has the asymptotic expansion as .
- The following option can be given:
Method Automatic method to use ProgressReporting False whether to report the progress of the computation
- Possible settings for Method include:
"DelegliseRivat" use the Deléglise–Rivat algorithm "Legendre" use the Legendre formula "Lehmer" use the Lehmer formula "LMO" use the Lagarias–Miller–Odlyzko algorithm "Meissel" use the Meissel formula "Sieve" use the sieve of Erastosthenes
Examplesopen allclose all
Basic Examples (3)
Numerical Manipulation (5)
Specify the Legendre method to be used for counting primes [MathWorld]:
Specify the Lehmer method to be used for counting primes [MathWorld]:
Specify the Deléglise–Rivat method to be used for counting primes:
Specify the Meissel method to be used for counting primes [MathWorld]:
Specify the Lagarias–Miller–Odlyzko (LMO) to be used for counting primes:
By default, PrimePi does not report progress:
With the setting ProgressReporting->True, PrimePi shows the progress of the computation:
Basic Applications (7)
Approximations to PrimePi:
Plot PrimePi compared with estimates:
is bounded below by and is bounded above by for greater than 3:
for if the Riemann hypothesis is true:
Count the prime numbers using EulerPhi:
Compute PrimePi based on the Hardy–Wright formula:
Compute PrimePi using Accumulate:
Number Theory (8)
Find twin primes up to , i.e. pairs of primes of the form :
Plot the sequence of twin primes and PrimePi:
The Ramanujan prime is the smallest number such that for all :
Plot the sequence of Ramanujan primes:
Compare the count of Ramanujan primes to PrimePi:
Calculate the primorial up to the prime, i.e. a function that multiplies successive primes, similar to the factorial:
Compare the primorial to the factorial up to :
Plot the differences between the factorial and the primorial up to :
Plot the Chebyshev theta function:
Calculate the prime powers up to :
Count all the prime powers up to :
Graph the count of prime powers:
Compare the count of prime powers to PrimePi:
Visualize the second Hardy–Littlewood conjecture, which states that for :
Plot Brocard's conjecture, which states that if and are consecutive primes greater than 2, then between and there are at least four prime numbers:
Find Goldbach partitions, i.e. pairs of primes (, ) such that :
Graph Goldbach's conjecture/comet:
Properties & Relations (5)
Wolfram Research (1991), PrimePi, Wolfram Language function, https://reference.wolfram.com/language/ref/PrimePi.html (updated 2021).
Wolfram Language. 1991. "PrimePi." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/PrimePi.html.
Wolfram Language. (1991). PrimePi. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PrimePi.html