In 1972, the physicist Freeman Dyson wrote an article called “Missed Opportunities.” In it, he describes how relativity could have been discovered many years before Einstein announced his findings if mathematicians in places like Göttingen had spoken to physicists who were poring over Maxwell’s equations describing electromagnetism. The ingredients were there in 1865 to make the breakthrough—only announced by Einstein some 40 years later.

It is striking that Dyson should have written about scientific ships passing in the night. Shortly after he published the piece, he was responsible for an abrupt collision between physics and mathematics that produced one of the most remarkable scientific ideas of the last half century: that quantum physics and prime numbers are inextricably linked.

This unexpected connection with physics has given us a glimpse of the mathematics that might, ultimately, reveal the secret of these enigmatic numbers. At first the link seemed rather tenuous. But the important role played by the number 42 has recently persuaded even the deepest skeptics that the subatomic world might hold the key to one of the greatest unsolved problems in mathematics.

Prime numbers, such as 17 and 23, are those that can only be divided by themselves and one. They are the most important objects in mathematics because, as the ancient Greeks discovered, they are the building blocks of all numbers—any of which can be broken down into a product of primes. (For example, 105 = 3 x 5 x 7.) They are the hydrogen and oxygen of the world of mathematics, the atoms of arithmetic. They also represent one of the greatest challenges in mathematics.

As a mathematician, I’ve dedicated my life to trying to find patterns, structure and logic in the apparent chaos that surrounds me. Yet this science of patterns seems to be built from a set of numbers which have no logic to them at all. The primes look more like a set of lottery ticket numbers than a sequence generated by some simple formula or law.

For 2,000 years the problem of the pattern of the primes—or the lack thereof—has been like a magnet, drawing in perplexed mathematicians. Among them was Bernhard Riemann who, in 1859, the same year Darwin published his theory of evolution, put forward an equally-revolutionary thesis for the origin of the primes. Riemann was the mathematician in Göttingen responsible for creating the geometry that would become the foundation for Einstein’s great breakthrough. But it wasn’t only relativity that his theory would unlock.

Riemann discovered a geometric landscape, the contours of which held the secret to the way primes are distributed through the universe of numbers. He realized that he could use something called the zeta function to build a landscape where the peaks and troughs in a three-dimensional graph correspond to the outputs of the function. The zeta function provided a bridge between the primes and the world of geometry. As Riemann explored the significance of this new landscape, he realized that the places where the zeta function outputs zero (which correspond to the troughs, or places where the landscape dips to sea-level) hold crucial information about the nature of the primes. Mathematicians call these significant places the zeros.

Riemann’s discovery was as revolutionary as Einstein’s realization that E=mc2. Instead of matter turning into energy, Riemann’s equation transformed the primes into points at sea-level in the zeta landscape. But then Riemann noticed that it did something even more incredible. As he marked the locations of the first 10 zeros, a rather amazing pattern began to emerge. The zeros weren’t scattered all over; they seemed to be running in a straight line through the landscape. Riemann couldn’t believe this was just a coincidence. He proposed that all the zeros, infinitely many of them, would be sitting on this critical line—a conjecture that has become known as the Riemann Hypothesis.

But what did this amazing pattern mean for the primes? If Riemann’s discovery was right, it would imply that nature had distributed the primes as fairly as possible. It would mean that the primes behave rather like the random molecules of gas in a room: Although you might not know quite where each molecule is, you can be sure that there won’t be a vacuum at one corner and a concentration of molecules at the other.

For mathematicians, Riemann’s prediction about the distribution of primes has been very powerful. If true, it would imply the viability of thousands of other theorems, including several of my own, which have had to assume the validity of Riemann’s Hypothesis to make further progress. But despite nearly 150 years of effort, no one has been able to confirm that all the zeros really do line up as he predicted.

It was a chance meeting between physicist Freeman Dyson and number theorist Hugh Montgomery in 1972, over tea at Princeton’s Institute for Advanced Study, that revealed a stunning new connection in the story of the primes—one that might finally provide a clue about how to navigate Riemann’s landscape. They discovered that if you compare a strip of zeros from Riemann’s critical line to the experimentally recorded energy levels in the nucleus of a large atom like erbium, the 68th atom in the periodic table of elements, the two are uncannily similar.

It seemed the patterns Montgomery was predicting for the way zeros were distributed on Riemann’s critical line were the same as those predicted by quantum physicists for energy levels in the nucleus of heavy atoms. The implications of a connection were immense: If one could understand the mathematics describing the structure of the atomic nucleus in quantum physics, maybe the same math could solve the Riemann Hypothesis.

Mathematicians were skeptical. Though mathematics has often served physicists—Einstein, for instance—they wondered whether physics could really answer hard-core problems in number theory. So in 1996, Peter Sarnak at Princeton threw down the gauntlet and challenged physicists to tell the mathematicians something they didn’t know about primes. Recently, Jon Keating and Nina Snaith, of Bristol, duely obliged.

There is an important sequence of numbers called “the moments of the Riemann zeta function.” Although we know abstractly how to define it, mathematicians have had great difficulty explicitly calculating the numbers in the sequence. We have known since the 1920s that the first two numbers are 1 and 2, but it wasn’t until a few years ago that mathematicians conjectured that the third number in the sequence may be 42—a figure greatly significant to those well-versed in The Hitchhiker’s Guide to the Galaxy.

It would also prove to be significant in confirming the connection between primes and quantum physics. Using the connection, Keating and Snaith not only explained why the answer to life, the universe and the third moment of the Riemann zeta function should be 42, but also provided a formula to predict all the numbers in the sequence. Prior to this breakthrough, the evidence for a connection between quantum physics and the primes was based solely on interesting statistical comparisons. But mathematicians are very suspicious of statistics. We like things to be exact. Keating and Snaith had used physics to make a very precise prediction that left no room for the power of statistics to see patterns where there are none.

Mathematicians are now convinced. That chance meeting in the common room in Princeton resulted in one of the most exciting recent advances in the theory of prime numbers. Many of the great problems in mathematics, like Fermat’s Last Theorem, have only been cracked once connections were made to other parts of the mathematical world. For 150 years many have been too frightened to tackle the Riemann Hypothesis. The prospect that we might finally have the tools to understand the primes has persuaded many more mathematicians and physicists to take up the challenge. The feeling is in the air that we might be one step closer to a solution. Dyson might be right that the opportunity was missed to discover relativity 40 years earlier, but who knows how long we might still have had to wait for the discovery of connections between primes and quantum physics had mathematicians not enjoyed a good chat over tea. Marcus du Sautoy is professor of mathematics at the University of Oxford, and is the author of The Music of the Primes (HarperCollins).