Real-world applications of prime numbers?

Here is a hypothesized real-world application, but it's not by humans...it's by cicadas.

Cicadas are insects which hibernate underground and emerge every 13 or 17 years to mate and die (while the newborn cicadas head underground to repeat the process). Some people have speculated that the 13/17-year hibernation is the result of evolutionary pressures. If cicadas hibernated for X years and had a predator which underwent similar multi-year hibernations, say for Y years, then the cicadas would get eaten if Y divided X. So by "choosing" prime numbers, they made their predators much less likely to wake up at the right time.

(It doesn't matter much anyway, because as I understand it, all of the local bug-eating animals absolutely gorge themselves whenever the cicadas come out!)


EDIT: I should have refreshed my memory before posting. I just re-read the article, and the cicadas do not hibernate underground. They apparently "suckle on tree roots". The article has a few other mild corrections to my answer, as well.


The most popular example I know comes from Cryptography, where many systems rely on problems in number theory, where primes have an important role (since primes are in a sense the "building blocks" of numbers).

Take for example the RSA encryption system: All arithmetic is done modulo $n$, with $n=pq$ and $p,q$ large primes. Decryption in this system relies on computing Euler's phi function, $\varphi(n)$, which is hard to compute (hence the system is hard to break) unless you know the prime factorization of $n$ (which is also hard to compute unless you know it upfront). Hence you need a method to generate primes (the Miller-Rabin primality checking algorithm is usually used here) and then you construct $n$ by multiplying the primes you have found.


When I was some 20 years old and living by myself for the first time, I designed a little racetrack with numbered squares on it, along with a handful of coloured tokens that would race along the track at the speed of one square per day. Each token had a household chore and a prime number on it; when a token hit its number, I had to carry out the given task, and it would get reset to zero. So, I washed the dishes every two days, watered the plants every three, vacuumed the carpet every five, ....

It was a good system. It made cleaning fun, it provided variety and structure at the same time, and I was obliged to devote the entire day to chores only once every 1397.73 years.


You can use prime numbers to plot this fine pattern :)

enter image description here

Intensity of green colour for each pixel was calculated using a function, which can be described with this pseudocode snippet:

g_intensity = ((((y << 32) | x))^((x << 32) | y))) * 15731 + 1376312589) % 256

where x and y are a pixel coordinates in screen space, stored in a 64bit integer variables.


Just to add one more: Primes are also useful when generating Pseudo-Random Numbers with the computer. A few formulas use them to avoid patterns in the output.