In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, the prime-counting function is the
function counting the number of
prime number
A prime number (or a prime) is a natural number greater than 1 that is not a Product (mathematics), product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime ...
s less than or equal to some
real number
In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
.
It is denoted by (unrelated to the
number ).
A symmetric variant seen sometimes is , which is equal to if is exactly a prime number, and equal to otherwise. That is, the number of prime numbers less than , plus half if equals a prime.
Growth rate
Of great interest in
number theory
Number theory is a branch of pure mathematics devoted primarily to the study of the integers and arithmetic functions. Number theorists study prime numbers as well as the properties of mathematical objects constructed from integers (for example ...
is the
growth rate of the prime-counting function.
It was
conjecture
In mathematics, a conjecture is a conclusion or a proposition that is proffered on a tentative basis without proof. Some conjectures, such as the Riemann hypothesis or Fermat's conjecture (now a theorem, proven in 1995 by Andrew Wiles), ha ...
d in the end of the 18th century by
Gauss
Johann Carl Friedrich Gauss (; ; ; 30 April 177723 February 1855) was a German mathematician, astronomer, Geodesy, geodesist, and physicist, who contributed to many fields in mathematics and science. He was director of the Göttingen Observat ...
and by
Legendre to be approximately
where is the
natural logarithm
The natural logarithm of a number is its logarithm to the base of a logarithm, base of the e (mathematical constant), mathematical constant , which is an Irrational number, irrational and Transcendental number, transcendental number approxima ...
, in the sense that
This statement is the
prime number theorem
In mathematics, the prime number theorem (PNT) describes the asymptotic analysis, asymptotic distribution of the prime numbers among the positive integers. It formalizes the intuitive idea that primes become less common as they become larger by p ...
. An equivalent statement is
where is the
logarithmic integral function. The prime number theorem was first proved in 1896 by
Jacques Hadamard and by
Charles de la Vallée Poussin independently, using properties of the
Riemann zeta function introduced by
Riemann in 1859. Proofs of the prime number theorem not using the zeta function or
complex analysis
Complex analysis, traditionally known as the theory of functions of a complex variable, is the branch of mathematical analysis that investigates functions of complex numbers. It is helpful in many branches of mathematics, including algebraic ...
were found around 1948 by
Atle Selberg
Atle Selberg (14 June 1917 – 6 August 2007) was a Norwegian mathematician known for his work in analytic number theory and the theory of automorphic forms, and in particular for bringing them into relation with spectral theory. He was awarded ...
and by
Paul Erdős (for the most part independently).
More precise estimates
In 1899,
de la Vallée Poussin proved that
for some positive constant . Here, is the
big notation.
More precise estimates of are now known. For example, in 2002,
Kevin Ford proved that
Mossinghoff and
Trudgian proved an explicit upper bound for the difference between and :
For values of that are not unreasonably large, is greater than . However, is known to change sign infinitely many times. For a discussion of this, see
Skewes' number.
Exact form
For let when is a prime number, and otherwise.
Bernhard Riemann
Georg Friedrich Bernhard Riemann (; ; 17September 182620July 1866) was a German mathematician who made profound contributions to analysis, number theory, and differential geometry. In the field of real analysis, he is mostly known for the f ...
, in his work ''
On the Number of Primes Less Than a Given Magnitude'', proved that is equal to
where
is the
Möbius function
The Möbius function \mu(n) is a multiplicative function in number theory introduced by the German mathematician August Ferdinand Möbius (also transliterated ''Moebius'') in 1832. It is ubiquitous in elementary and analytic number theory and m ...
, is the
logarithmic integral function
In mathematics, the logarithmic integral function or integral logarithm li(''x'') is a special function. It is relevant in problems of physics and has number theory, number theoretic significance. In particular, according to the prime number the ...
, indexes every zero of the Riemann zeta function, and is not evaluated with a
branch cut but instead considered as where is the
exponential integral
In mathematics, the exponential integral Ei is a special function on the complex plane.
It is defined as one particular definite integral of the ratio between an exponential function and its argument.
Definitions
For real non-zero values of&nb ...
. If the trivial zeros are collected and the sum is taken ''only'' over the non-trivial zeros of the Riemann zeta function, then may be approximated by
The
Riemann hypothesis
In mathematics, the Riemann hypothesis is the conjecture that the Riemann zeta function has its zeros only at the negative even integers and complex numbers with real part . Many consider it to be the most important unsolved problem in pure ...
suggests that every such non-trivial zero lies along .
Table of , , and
The table shows how the three functions , , and compared at powers of 10. See also,
and
:

In the
On-Line Encyclopedia of Integer Sequences
The On-Line Encyclopedia of Integer Sequences (OEIS) is an online database of integer sequences. It was created and maintained by Neil Sloane while researching at AT&T Labs. He transferred the intellectual property and hosting of the OEIS to th ...
, the column is sequence , is sequence , and is sequence .
The value for was originally computed by J. Buethe,
J. Franke, A. Jost, and T. Kleinjung assuming the
Riemann hypothesis
In mathematics, the Riemann hypothesis is the conjecture that the Riemann zeta function has its zeros only at the negative even integers and complex numbers with real part . Many consider it to be the most important unsolved problem in pure ...
.
It was later verified unconditionally in a computation by D. J. Platt.
The value for is by the same four authors.
[ Includes 600,000 value of for ]
The value for was computed by D. B. Staple.
All other prior entries in this table were also verified as part of that work.
The values for 10
27, 10
28, and 10
29 were announced by David Baugh and Kim Walisch in 2015, 2020, and 2022, respectively.
Algorithms for evaluating
A simple way to find , if is not too large, is to use the
sieve of Eratosthenes to produce the primes less than or equal to and then to count them.
A more elaborate way of finding is due to
Legendre (using the
inclusion–exclusion principle): given , if are distinct prime numbers, then the number of integers less than or equal to which are divisible by no is
:
(where denotes the
floor function
In mathematics, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least integer greater than or eq ...
). This number is therefore equal to
:
when the numbers are the prime numbers less than or equal to the square root of .
The Meissel–Lehmer algorithm
In a series of articles published between 1870 and 1885,
Ernst Meissel described (and used) a practical combinatorial way of evaluating : Let be the first primes and denote by the number of natural numbers not greater than which are divisible by none of the for any . Then
:
Given a natural number , if and if , then
:
Using this approach, Meissel computed , for equal to , 10
6, 10
7, and 10
8.
In 1959,
Derrick Henry Lehmer extended and simplified Meissel's method. Define, for real and for natural numbers and , as the number of numbers not greater than with exactly prime factors, all greater than . Furthermore, set . Then
:
where the sum actually has only finitely many nonzero terms. Let denote an integer such that , and set . Then and when . Therefore,
:
The computation of can be obtained this way:
:
where the sum is over prime numbers.
On the other hand, the computation of can be done using the following rules:
#
#
Using his method and an
IBM 701, Lehmer was able to compute the correct value of and missed the correct value of by 1.
Further improvements to this method were made by Lagarias, Miller, Odlyzko, Deléglise, and Rivat.
Other prime-counting functions
Other prime-counting functions are also used because they are more convenient to work with.
Riemann's prime-power counting function
Riemann's prime-power counting function is usually denoted as or . It has jumps of at prime powers and it takes a value halfway between the two sides at the discontinuities of . That added detail is used because the function may then be defined by an inverse
Mellin transform.
Formally, we may define by
:
where the variable in each sum ranges over all primes within the specified limits.
We may also write
:
where is the
von Mangoldt function
In mathematics, the von Mangoldt function is an arithmetic function named after German mathematician Hans von Mangoldt. It is an example of an important arithmetic function that is neither multiplicative nor additive.
Definition
The von Mang ...
and
:
The
Möbius inversion formula then gives
:
where is the
Möbius function
The Möbius function \mu(n) is a multiplicative function in number theory introduced by the German mathematician August Ferdinand Möbius (also transliterated ''Moebius'') in 1832. It is ubiquitous in elementary and analytic number theory and m ...
.
Knowing the relationship between the logarithm of the
Riemann zeta function and the
von Mangoldt function
In mathematics, the von Mangoldt function is an arithmetic function named after German mathematician Hans von Mangoldt. It is an example of an important arithmetic function that is neither multiplicative nor additive.
Definition
The von Mang ...
, and using the
Perron formula we have
:
Chebyshev's function
The
Chebyshev function weights primes or prime powers by :
:
For ,
:
and
:
Formulas for prime-counting functions
Formulas for prime-counting functions come in two kinds: arithmetic formulas and analytic formulas. Analytic formulas for prime-counting were the first used to prove the
prime number theorem
In mathematics, the prime number theorem (PNT) describes the asymptotic analysis, asymptotic distribution of the prime numbers among the positive integers. It formalizes the intuitive idea that primes become less common as they become larger by p ...
. They stem from the work of Riemann and
von Mangoldt, and are generally known as
explicit formulae.
We have the following expression for the second
Chebyshev function :
:
where
:
Here are the zeros of the Riemann zeta function in the critical strip, where the real part of is between zero and one. The formula is valid for values of greater than one, which is the region of interest. The sum over the roots is conditionally convergent, and should be taken in order of increasing absolute value of the imaginary part. Note that the same sum over the trivial roots gives the last
subtrahend in the formula.
For we have a more complicated formula
:
Again, the formula is valid for , while are the nontrivial zeros of the zeta function ordered according to their absolute value. The first term is the usual
logarithmic integral function
In mathematics, the logarithmic integral function or integral logarithm li(''x'') is a special function. It is relevant in problems of physics and has number theory, number theoretic significance. In particular, according to the prime number the ...
; the expression in the second term should be considered as , where is the
analytic continuation
In complex analysis, a branch of mathematics, analytic continuation is a technique to extend the domain of definition of a given analytic function. Analytic continuation often succeeds in defining further values of a function, for example in a ne ...
of the
exponential integral
In mathematics, the exponential integral Ei is a special function on the complex plane.
It is defined as one particular definite integral of the ratio between an exponential function and its argument.
Definitions
For real non-zero values of&nb ...
function from negative reals to the complex plane with branch cut along the positive reals. The final integral is equal to the series over the trivial zeros:
:
Thus,
Möbius inversion formula gives us
:
valid for , where
:
is Riemann's R-function
and is the
Möbius function
The Möbius function \mu(n) is a multiplicative function in number theory introduced by the German mathematician August Ferdinand Möbius (also transliterated ''Moebius'') in 1832. It is ubiquitous in elementary and analytic number theory and m ...
. The latter series for it is known as
Gram
The gram (originally gramme; SI unit symbol g) is a Physical unit, unit of mass in the International System of Units (SI) equal to one thousandth of a kilogram.
Originally defined in 1795 as "the absolute Mass versus weight, weight of a volume ...
series.
Because for all , this series converges for all positive by comparison with the series for . The logarithm in the Gram series of the sum over the non-trivial zero contribution should be evaluated as and not .
Folkmar Bornemann proved, when assuming the
conjecture
In mathematics, a conjecture is a conclusion or a proposition that is proffered on a tentative basis without proof. Some conjectures, such as the Riemann hypothesis or Fermat's conjecture (now a theorem, proven in 1995 by Andrew Wiles), ha ...
that all zeros of the Riemann zeta function are simple,
[ Montgomery showed that (assuming the Riemann hypothesis) at least two thirds of all zeros are simple.] that
:
where runs over the non-trivial zeros of the Riemann zeta function and .
The sum over non-trivial zeta zeros in the formula for describes the fluctuations of while the remaining terms give the "smooth" part of prime-counting function,
so one can use
:
as a good estimator of for . In fact, since the second term approaches 0 as , while the amplitude of the "noisy" part is heuristically about , estimating by alone is just as good, and fluctuations of the
distribution of primes may be clearly represented with the function
:
Inequalities
Ramanujan proved that the inequality
:
holds for all sufficiently large values of .
Here are some useful inequalities for .
:
The left inequality holds for and the right inequality holds for . The constant is to 5 decimal places, as has its maximum value at .
Pierre Dusart proved in 2010:
:
More recently, Dusart has proved
(Theorem 5.1) that
:
for and , respectively.
Going in the other direction, an approximation for the th prime, , is
:
Here are some inequalities for the th prime. The lower bound is due to Dusart (1999) and the upper bound to Rosser (1941).
:
The left inequality holds for and the right inequality holds for . A variant form sometimes seen substitutes
An even simpler lower bound is
:
which holds for all , but the lower bound above is tighter for .
In 2010 Dusart proved
(Propositions 6.7 and 6.6) that
:
for and , respectively.
In 2024, Axler further tightened this (equations 1.12 and 1.13) using bounds of the form
:
proving that
:
for and , respectively.
The lower bound may also be simplified to without altering its validity. The upper bound may be tightened to if .
There are additional bounds of varying complexity.
The Riemann hypothesis
The
Riemann hypothesis
In mathematics, the Riemann hypothesis is the conjecture that the Riemann zeta function has its zeros only at the negative even integers and complex numbers with real part . Many consider it to be the most important unsolved problem in pure ...
implies a much tighter bound on the error in the estimate for , and hence to a more regular distribution of prime numbers,
:
Specifically,
:
proved that the Riemann hypothesis implies that for all there is a prime satisfying
:
See also
*
Bertrand's postulate
In number theory, Bertrand's postulate is the theorem that for any integer n > 3, there exists at least one prime number p with
:n < p < 2n - 2.
A less restrictive formulation is: for every , there is always at least one ...
*
Oppermann's conjecture
*
Ramanujan prime
References
Notes
External links
*Chris Caldwell
''The Nth Prime Page''at The
Prime Pages
The PrimePages is a website about prime number
A prime number (or a prime) is a natural number greater than 1 that is not a Product (mathematics), product of two smaller natural numbers. A natural number greater than 1 that is not prime is ...
.
*Tomás Oliveira e Silva
Tables of prime-counting functions
*
{{DEFAULTSORT:Prime-Counting Function
Analytic number theory
Prime numbers
Arithmetic functions