Prime numbers have intrigued, baffled, and amazed us for millennia. 

They're often thought of as the building blocks of mathematics, but one of their most fascinating properties is that they appear to occur randomly - which is why mathematicians spend so long searching for the next highest prime (the last one we found was 23,249,425 digits in size).

Still, give humans something that seems purely random, and we can't help ourselves but look for a hidden meaning, or a pattern to make sense of it.

This isn't just for laughs, either; the randomness of prime numbers forms a basis of a form of encryption called an RSA algorithm.

Now a team of chemists claims they've found a unique pattern hidden in the distribution of prime numbers - when you consider them as a physical structure, that is.

Instead of looking at primes from a purely mathematical perspective, theoretical chemist Salvatore Torquato looked at primes as if they were tiny atoms within a crystal.

The way we study the patterns of atoms in crystals is by hitting them with X-rays and seeing how rays scatter, a process known as X-ray diffraction. 

Different materials produce different patterns - liquids, for example, which have atoms jiggling all around in no clear structure, scatter X-rays around randomly with no set diffraction pattern.

Crystals, on the other hand, have a rigid structure of atoms and they produce an orderly diffraction pattern with clear peaks and troughs, known as "Bragg peaks", named after father-and-son physicists William and Lawrence Bragg.

Based on this principle, if prime numbers were part of a physical structure, it would behave more like a chaotic liquid. 

But when Torquato teamed up with a couple of number theorists and created a computer model that would 'bounce' theoretical X-rays off a million or so prime numbers, they found something intriguing. The prime numbers actually produced a crystal-like diffraction pattern.

Perhaps most interesting is the fact that the pattern they saw was unlike any other crystal pattern they've seen so far.

It was what we might compare to a quasicrystal – materials that have some of the symmetrical properties of crystals, but arranged in an amorphous fashion.

"The primes are actually suggesting a completely different state of particle positions that are like quasicrystals but are not like quasicrystals," Torquato told Quanta Magazine's Natalie Wolchover, referring to the patterns as "a completely new category of structures" when primes are looked at like a physical system.

This isn't exactly the big reveal pointing the way to some fundamental law of the Universe. But it doesn't mean encryption experts have a reason to be at least a little concerned.

"Our formulation also yields an algorithm that enables one to predict (reconstruct) primes with high accuracy," the trio write in their paper.

The mathematics itself isn't revolutionary, being based on some well-established processes. There have also been other patterns detected among groups of primes that have attracted interest over the years.

It is, however, remarkable for the fact it was inspired by a completely different field of research. And it shows a bridge between materials science and mathematics - specifically prime numbers and crystals.

Henry Cohn, a researcher at Microsoft Research who was not involved with the study, explained in a Princeton University piece on the discovery: "it's a beautiful new perspective on this information, and it opens up new connections with materials science and scattering theory."

The work also sets the groundwork for further investigation that could yet uncover something interesting not just about the large-scale aggregation of primes, but of the potential for how any set of particles might arrange.

The research was published in the Journal of Statistical Mechanics: Theory and Experiment.