WorksMathematics
The Riemann Hypothesis and Prime Numbers
Abstract
The Riemann hypothesis is attracting a great deal of attention at present. It is one of the seven Millennium Prize Problems in mathematics, for each of which the Clay Mathematics Institute offers a prize of one million dollars. It is arguably the most important open problem in all of mathematics. Numerous results have so far been proved only under the assumption of the Riemann hypothesis. Yet the hypothesis itself sounds rather dull: it conjectures that the zeros of a certain function have a certain form. Things become truly exciting, however, when we look at its connection with prime numbers, and that is what we shall do here.
Prime Numbers
We begin with a definition: a natural number divides a natural number if there is a natural number such that . We write . Prime numbers are natural numbers with exactly two positive divisors. Thus, the divisors of a prime number are and . It is known that there are infinitely many prime numbers.
The first prime numbers are:
We shall need the following theorem, also known as the fundamental theorem of arithmetic.
Theorem 1 Every natural number can be expressed as a product of prime numbers. Apart from the order of the factors, this representation is unique: has exactly one prime factorization.
For example, we can write . In general, every natural number can be written as , where the are distinct primes and .
At first sight, the primes seem completely disordered. Sometimes they lie close together; at other times there are larger gaps. For example, one can find very large twin primes, that is, pairs of primes whose difference is 2. Whether there are infinitely many twin primes is still an open question. On the other hand, one can find arbitrarily long sequences of consecutive natural numbers, none of which is prime: The numbers , , , are all nonprime for because is divisible by .
Here is a Julia program for finding twin primes (further information on the Julia programming language can be found in [8]).
# Simple primality test
function isprime(n::Int)
if n < 2 return false end
if n % 2 == 0 return n == 2 end
limit = floor(Int, sqrt(n))
for i in 3:2:limit
if n % i == 0 return false end
end
return true
end
# Next pair of twin primes greater than n
function next_twin_prime(n::Int)
p = max(n+1, 2)
# Make p odd.
if p % 2 == 0 p += 1 end
while true
if isprime(p) && isprime(p+2)
return (p, p+2)
end
p += 2
end
end
The program is self-explanatory. Call it with any natural number, and it returns the next pair of twin primes above that number.
julia> next_twin_prime(3123425343452376402)
(3123425343452376749, 3123425343452376751)
It therefore seems as though the primes have no structure. Tables can give us an impression of their distribution. Let denote the number of primes between and .
| 0 – 100000 | 9592 |
| 100000 – 200000 | 8392 |
| 200000 – 300000 | 8013 |
| 300000 – 400000 | 7863 |
| 400000 – 500000 | 7678 |
| 500000 – 600000 | 7560 |
| 600000 – 700000 | 7445 |
| 700000 – 800000 | 7408 |
| 800000 – 900000 | 7323 |
| 900000 – 1000000 | 7224 |
Table 2.
This suggests that there may be some underlying structure after all. The average density decreases in the long run. How exactly does it decrease?
In 1792, at the age of fifteen, Carl Friedrich Gauss studied tables of primes, which could then be purchased as booklets, to understand these distributions. He formulated a conjecture that was proved only a hundred years later by Hadamard and, independently, by de la Vallée Poussin. This conjecture became known as the “prime number theorem.” In what follows, let denote the number of primes less than or equal to . For example, , since there are three primes less than or equal to either 5 or 6.
The following Julia program, prime_pi(x), computes the function . It uses the function pi_tabelle(N), which applies the sieve of Eratosthenes to build a table of prime counts up to a given number .
function pi_tabelle(N::Integer)
is_prime = trues(N)
is_prime[1] = false # 1 is not prime.
for p in 2:isqrt(N)
if is_prime[p]
for multiple in (p * p):p:N
is_prime[multiple] = false
end
end
end
return cumsum(vcat(0, Int.(is_prime)))
end
"""Number of primes less than or equal to a real number x."""
function prime_pi(x::Real)
x < 2 && return 0
return pi_tabelle(floor(Int, x))[end]
end
The central line of the sieve is
for multiple in (p * p):p:N is_prime[multiple] = false
Starting at and continuing up to , every th entry is crossed out, that is, set to false in is_prime.
Plotting the graph of gives Figure 1. The regularity of the curve is astonishing. There must be some structure behind it.

Figure 1. The prime-counting function for .
The following table lists the values of . We observe that, for larger values of , they increase by about 2.3 from one power of ten to the next.
We have , where denotes the natural logarithm of . This suggests:
If this holds for , perhaps it holds more generally: , and hence . This was Gauss’s discovery.
Theorem 2 Prime Number Theorem. As increases, approaches the function given by in the following sense:
One can interpret this as follows: the “probability” that a randomly chosen number is prime is approximately
The relative frequency of primes among all numbers up to , namely , is therefore approximately . This leads to another good approximation to , first proposed by Gauss. The idea is to assign each number a weight corresponding to the approximate density of primes in its neighborhood.
First, we can write the prime-counting function exactly as a sum. For natural numbers ,
The individual values jump irregularly between 0 and 1. Gauss’s idea is to replace these irregular contributions by smooth average contributions. His heuristic is:
Near a large number , approximately a proportion of the numbers are prime.
For example,
Intuitively, this means that in a suitable range near 1000, we expect about 14.5 % of the numbers to be prime. For a fixed number, of course, whether it is prime is completely determined; the “probability” here describes an average frequency.
We therefore approximately replace the contribution in (1) by . Adding these weights gives
This takes into account the fact that prime density decreases as increases: smaller numbers receive larger weights, and larger numbers receive smaller weights. The simpler approximation uses the same value throughout the whole range. The sum can in turn be approximated by the area under the graph of :
We therefore expect
This approximation is somewhat more accurate than the one in the prime number theorem. We define
Plotting and together gives Figure 2. Notice that always lies below

Figure 2. and for .
(at least for ). This remains the case when the graph is extended to much larger values of . However, it has been proved that and exchange places infinitely often. The first such crossing occurs for . We may never find this point: is simply too large.
The following statement is equivalent to the Riemann hypothesis (be patient—we shall introduce it later):
(RH’): For sufficiently large , the absolute error in Gauss’s approximation to is at most a constant multiple of , that is,
This can also be made more explicit. For example, the Riemann hypothesis is equivalent to
Schoenfeld proved this as early as 1976. This remains an active area of research.
A Formula of Euler
Let . It is easy to prove the formula
Expand by hand and show that all terms cancel except and .
Lemma 3 For , , and , we have
Proof. Substitute into formula (2):
As tends to infinity, tends to (since ), giving the claimed formula. □
Let be the set of prime numbers. Euler considered the product
By Lemma 3, we can rewrite this as
We obtain
In this product, the nonzero contributions are obtained by choosing a value different from 1 from only finitely many factors. Each such term has the form
where the are distinct primes and . Moreover, each possible term occurs exactly once. Recall Theorem 1, the theorem on unique prime factorization. The denominator on the right is the prime factorization of a natural number. Every natural number appears exactly once as a denominator. Thus we obtain the following formula, which Euler discovered in the eighteenth century:
This formula is another marvel. On the left is a product involving only primes. On the right, we sum over all natural numbers. At first sight, the expression on the right has nothing to do with primes at all! Yet somehow all the primes must be hidden in that sum. This must have caught Riemann’s attention.
The Riemann Zeta Function
Formula (3) defines a function of . The function
is called the Riemann zeta function. It is defined only for . For , we would have
and here the following result applies:
Theorem 4 The series diverges.
Proof: We group the terms into blocks:
The block
contains terms. Each is at least . Therefore,
Hence the partial sums satisfy
Since all terms are positive, the partial sums increase monotonically. Thus
□
Incidentally, this gives us a second proof that there are infinitely many primes. If there were only finitely many, the product on the left of formula (3) would be a finite number, whereas the right-hand side is infinite by the theorem just proved. This is a contradiction.
In 1859, Riemann wrote a groundbreaking paper [7]. His idea was to extend the function to complex numbers (the necessary background on complex numbers can be found, for example, in [4]). This makes a function defined for all complex numbers whose real part is greater than 1. We now have natural numbers raised to complex powers. How should we think about this?
Let be a natural number and let
We define . Euler’s formula (i.e. for ) gives
Thus the modulus is , while the angle is . For example, . For the reciprocal, we similarly have
These powers are defined for every complex exponent. The condition additionally guarantees that the series
converges absolutely, since
Let us look at a concrete example. Consider
Figure 3 shows an approximation to this function value in the complex plane. Taking only the first term would bring us to 1, as indicated by the arrow from 0 to 1. Adding the second term brings us to the tip of the second arrow. We have turned through , due to the factor , and traveled a distance of . The other two terms are handled in the same way. The point represents the function value obtained from the first four terms.

Figure 3. An approximation to .
To summarize, we have a function whose domain consists of the complex numbers with real part greater than 1. It is known—and Riemann already knew this—that has a unique holomorphic continuation (that is, a continuation that is complex differentiable everywhere) to the entire complex plane except for a simple pole at .
Figure 4 shows the modulus of the zeta function extended to . The pole is at 1, and we can see how the modulus grows in its neighborhood. Hasse’s series provides a formula for computing the zeta function throughout :

Figure 4. The modulus of the zeta function, with the pole at 1 excluded.
Let us experiment with Julia. The zeta function is implemented in Julia as zeta(s). It belongs to the SpecialFunctions package and accepts both real and complex arguments.
Install the package once in Julia:
import Pkg; Pkg.add("SpecialFunctions")
Then load it using
using SpecialFunctions
You can now compute function values:
zeta(2) # Approximately 1.6449340668482264
zeta(0) # -0.5
zeta(-1) # Approximately -0.083333333333333333
zeta(-2) # 0.0
In Julia, im denotes the imaginary unit .
s = 0.5 + 14.1im
w = zeta(s)
println("Function value: ", w)
println("Real part: ", real(w))
println("Imaginary part: ", imag(w))
println("Modulus: ", abs(w))
The Riemann Hypothesis
Consider the unique holomorphic continuation to of the function initially defined by for . We continue to denote it by . The -function has no zeros with real part greater than 1. This can be seen from the fact that is nonzero for real numbers . One can prove that the negative even integers, that is, , are zeros of . They are called the trivial zeros. There are also nontrivial zeros; indeed, it is known that there are infinitely many of them. An online database contains more than billion nontrivial zeros of the zeta function. All these zeros have real part .
In Table 1 are the first ten nontrivial zeros (Re denotes the real part and Im the imaginary part of a complex number). For every nontrivial zero, its complex conjugate, with the opposite imaginary part, is also a zero. For example, is also a zero.
| 10 | 4 | 2.5 |
| 100 | 25 | 4.0 |
| 1000 | 168 | 6.0 |
| 10000 | 1229 | 8.1 |
| 100000 | 9592 | 10.4 |
| 1000000 | 78498 | 12.7 |
| 10000000 | 664579 | 15.0 |
| 100000000 | 5761455 | 17.4 |
| 1000000000 | 50847534 | 19.7 |
| 10000000000 | 455052511 | 22.0 |
Table 1.
We can now state the Riemann hypothesis:
(RH): All nontrivial zeros of the Riemann zeta function have real part .
In the first section, we encountered conjecture (RH′), a statement about primes. Conjecture (RH) is an equivalent statement in analysis. The zeta function translates arithmetic statements about primes into analytic properties of functions. The connection is astonishing. In modern mathematics, one often tries to reformulate conjectures from one field in another in order to obtain a different approach, as in the Langlands program—but that is another story.
| 1 | 14.1347251417 | |
| 2 | 21.0220396388 | |
| 3 | 25.0108575801 | |
| 4 | 30.4248761259 | |
| 5 | 32.9350615877 | |
| 6 | 37.5861781588 | |
| 7 | 40.9187190121 | |
| 8 | 43.3270732809 | |
| 9 | 48.0051508812 | |
| 10 | 49.7738324777 |
Table 1 (PDF p. 13). The first ten nontrivial zeros of the Riemann zeta function with positive imaginary part. The imaginary parts are rounded to ten decimal places.
The line in the complex plane is called the critical line. The Riemann hypothesis can therefore also be stated as follows:
All nontrivial zeros of the Riemann zeta function lie on the critical line.
It is known that all nontrivial zeros lie in the critical strip, that is, for every nontrivial zero (these bounds have recently been slightly improved). Figure 5 shows part of the complex plane with the first trivial

Figure 5. The complex plane.
and nontrivial zeros.
Figure 6 shows a segment of the critical line and its image under . We can see the image curve repeatedly passing through 0. The Riemann hypothesis has many consequences, for example for primality tests, elliptic curves, endomorphism rings, and much more. In his paper [7], Riemann himself developed an analytic formula for . In the next section, we turn to another application.

Figure 6. The segment , , in the domain and its image under .
Wave Functions
Let be the imaginary parts of the nontrivial zeros of the zeta function in the upper half-plane, arranged in increasing order. Thus , , and so on. Consider the functions . Figure 7 shows the function .

Figure 7. The function .
Figure 8 shows the function . It is very similar to , but somewhat compressed horizontally. We can superimpose these wave functions by adding them:

Figure 8. The function .
The resulting function is plotted in Figure 9. There are pronounced

Figure 9. .
downward spikes very close to the primes. We put the nontrivial zeros of the zeta function into , and out came the primes! Another marvel!
There are also somewhat smaller spikes at prime powers, namely 4, 8, 9, 16, 25, 27, and 32.
The zeros of the zeta function know everything about primes. This also works in reverse: the primes know the zeros of the zeta function. To see this, consider the function
where is the ith prime. Again, we add these functions:
Figure 10 shows the function . The spikes lie very close to the imaginary

Figure 10. The function .
parts of the nontrivial zeros of the zeta function. They do not occur at exactly those values because we have used only a finite sum for . A more precise mathematical treatment would show that we are investigating the zeros along the critical line.
The secret of the primes: they can be read off from the zeros of an analytic function.
The Divisor-Sum Conjecture
We define
Thus is the sum of all positive divisors of . For example,
It is known (and the proof is not difficult) that is multiplicative: if are coprime natural numbers, then . Thus, given the prime factorization , we have
It is easy to see that if is prime, then and . Together with Formula (2) we have
However, this formula allows us to compute only when we know the prime factorization of .
We also need the function
These are partial sums of the series considered in Theorem 4. The value is called the th harmonic number. In Julia, the command cumsum(1.0 ./ (1:n)) gives us . First, 1.0 ./ (1:n) produces the reciprocals , and cumsum adds them cumulatively.
The divisor-sum conjecture states:
(DS): For every natural number , the following inequality holds:
This conjecture can be formulated in entirely elementary terms. In 2000, Lagarias surprisingly proved that it is equivalent to the Riemann hypothesis (see [2]). Using Julia, we can plot the function
Figure 11 shows . All values in this range are positive, as expected. We can see how unevenly the values are distributed. They all appear to lie below a straight line.

Figure 11. The divisor-sum conjecture.
Hardy's Function
To conclude, let us experiment with Julia once more. Hardy’s -function (see [5]) is a function whose zeros are exactly the imaginary parts of the nontrivial zeros of the zeta function that lie on the critical line (these are all the nontrivial zeros if the Riemann hypothesis holds). We have
We cannot simply use as our real-valued function, because away from its zeros it takes complex values. The -function is defined by
where
is the Riemann–Siegel theta function. Here log denotes the complex natural logarithm, and is the gamma function. I shall not go into the details here. What matters is that the factor represents a rotation (its modulus is 1) that rotates the complex function values onto the real axis, so that the resulting function takes only real values.
The following program implements the -function in Julia:
using SpecialFunctions
# Riemann-Siegel theta function
function theta(x::Real)
return imag(loggamma(0.25 + 0.5im * x)) - (x / 2) * log(pi)
end
# Hardy’s Z-function
function Z(x::Real)
return real(exp(im * theta(x)) * zeta(0.5 + im * x))
end
In Figure 12, we have plotted part of the graph of the -function using the program above. We can see that its zeros correspond exactly to the first nontrivial zeros of the zeta function. The absolute values of the other function values agree exactly with the modulus of . In this sense, the -function visualizes the zeta function on the critical line. Looking at several plots over different ranges of the -axis reveals how chaotic the function’s behavior is.

Figure 12. The -function from 0 to 50.
AI was used in this article to generate some of the illustrations, to create the Julia programs and the bibliography, and to proofread the text.
Stephan Rosebrock Department of Mathematics Karlsruhe University of Education Bismarckstr. 10 76133 Karlsruhe, Germany Email: [email protected]
References
- [2]Jeffrey C. Lagarias; An Elementary Problem Equivalent to the Riemann Hypothesis; The American Mathematical Monthly 109, no. 6, pp. 534–543, 2002. https://arxiv.org/abs/math/0008177
- [4]Tristan Needham; Visual Complex Analysis; Oxford University Press, Oxford, 1997.
- [5]Aleksandar Ivić; Hardy’s Function Z(t)—Results and Problems; arXiv:1601.06512, 2016. https://arxiv.org/abs/1601.06512
- [7]Bernhard Riemann; On the Number of Prime Numbers Less Than a Given Quantity; 1859. English translation by David R. Wilkins, 1998. https://www.claymath.org/wp-content/uploads/2023/04/Wilkins-translation.pdf
- [8]The Julia Project; Julia Documentation. https://docs.julialang.org/en/v1/ Accessed November 13, 2026.DOI