We have seen already that there are infinitely many prime numbers. In other words, if we count the primes $p$ with $p \le n$ for a given natural number $n$ and let this number grow to infinity, the number of the primes we have to count will also grow to infinity. The question "how fast" this growth is one of the most key questions of number theory. The function which counts the number of primes in the described way an arithmetic function called the prime-counting function.

Definition: Prime-Counting Function

The prime-counting function is an arithmetic function, which is in the number theory traditionally denoted by $\pi:\mathbb N\to\mathbb N.$ It counts for an $n > 0$, $\pi(n)$ how many prime numbers $p\in\mathbb P$ are there which are smaller or equal $n$, i.e. $p\le n.$ In the sum notation, the function $\pi$ can be written as $$\pi(n):=\sum_{p\in\mathbb P,\; p\le n}1\quad\quad\forall n > 0.$$


The prime-counting function is a step function, the beginning of which can be visualized using SageMath. If you click on the evaluate button, you will see the values of $\pi(n)$ for $n=1,\ldots,100.$

plot(prime_pi(x), (x,1,100))

Examples: 1

Thank you to the contributors under CC BY-SA 4.0!




  1. Scheid Harald: "Zahlentheorie", Spektrum Akademischer Verlag, 2003, 3rd Edition
  2. Landau, Edmund: "Vorlesungen ├╝ber Zahlentheorie, Aus der Elementaren Zahlentheorie", S. Hirzel, Leipzig, 1927