From Messiaen to Radiohead: How great music uses prime numbers

- Olivier Messiaen’s music, especially his Quartet for the End of Time, uses prime number patterns to create a sense of timelessness and structural disorientation.
- The use of unsynchronized rhythms and harmonies—built on primes like 17 or 29—prevents any true repetition, mirroring the theme of time ending.
- This mathematical underpinning has inspired animations, contemporary artists like Radiohead, and reveals the deep connections between music, structure, and human perception.
I fell in love with Messiaen’s music in my late teenage years, after my youth orchestra spent a weekend playing through his explosive Turangalîla-Symphony. I think that weekend was the peak of my trumpet playing. It had to be. The trumpet part was crazily difficult. The whole piece was fiendish. Strange time signatures defied the usual three or four beats we were used to. But I remember being just blown away by the sheer ecstasy that Messiaen captured in the music.
That weekend spent inside Messiaen’s sound world reshaped my musical landscape. It wasn’t too long before I started exploring beyond that monumental piece, and Messiaen quickly became my favorite composer for many years. It was during that period that I listened for the first time to the Quartet for the End of Time on a CD I borrowed from our local library. The delicate chamber work was of a different order of magnitude than the symphony we’d played, but I was equally transfixed.
For years, I wasn’t able to articulate the strange structure that I heard at work in the opening movement. How was Messiaen able to achieve this curious effect in the piano part, where rhythm and harmony each individually repeated themselves in a regular pattern, and yet, when they were put together, the pattern vanished? What was Messiaen’s secret? It was only when I finally got a score that I was able to understand the blueprint Messiaen was exploiting. The answer turned out to be connected to one of my other teenage passions: prime numbers.
The rhythm of numbers
In the first movement of his piece, Messiaen wanted to create the strange sense of time ending. He achieved this in the most stunning manner. Time depends on things repeating, so he needed to produce a structure where you never truly hear the moment of repetition. While the clarinet imitates a blackbird and the violin a nightingale, the piano part plays a 17-note syncopated rhythm that just repeats itself over and over. But the chord sequence that the pianist plays, set to this rhythm sequence, consists of 29 chords, which are again repeated over and over. Such repeating patterns might lead to boredom and predictability, but not in this case. Because Messiaen’s choice of numbers—17 and 29—means that something rather magical… or mathematical, occurs. The numbers he chose are prime numbers, and their mutual indivisibility means that the rhythm and harmony that Messiaen has set up never get back in sync once the piece is in motion.
The two musical ideas set off at the beginning of the piece, but as the 17-note rhythm sequence begins its second cycle, the harmonic sequence is still working its way through its 29 chords. It’s only about 3/5ths through its sequence. Or, to be precise, 17/29ths of the way through. But once the harmonic sequence begins its second cycle, we are still five notes from finishing the second cycle of rhythm. The two musical ideas are kept out of sync. The choice of two prime numbers means that they don’t get back in step until you have heard 17×29=493 chords, by which time the piece has already finished. You never actually get a moment of true repetition.
It’s like two cogs, one with 17 teeth and the other with 29 teeth. As the interlocked cogs turn, they will have to go through 493 clicks before they simultaneously return to their original starting positions. Indeed, cogs in machines often are manufactured with a prime number of teeth precisely so that, as they turn, they will encounter different teeth on the cog they are engaging with, which evens out the wear on the teeth.
If you make different choices—for example, an 18-note rhythm sequence against 30 chords—then after 90 chords, you are back in sync because 90 is the smallest number divisible by 30 and 18. The different primes 17 and 29 keep the two out of sync so that the piece finishes before you ever hear the music repeat itself. This continually shifting and changing music creates, for Messiaen, the sense of timelessness that he was keen to establish. Although the music is moving forward, the fact that there is no true repetition makes the time strangely stand still. Messiaen even adds another cog to this effect by having the cello repeat a 15-harmonic sequence against what the piano is doing. It has been calculated that it would take two hours for the three cogs to work their way through every position. The actual movement is over in under three minutes.
Prime time animation
The idea of these cogs ticking as the piece progresses was the inspiration for an animation that I made with artist Simon Russell to explore the mathematics hiding inside the first movement of the Quartet for the End of Time. The animation begins inside a mathematical garden, but as the animation pans out while the piece progresses, you discover that this garden is in fact a prison, alluding to the venue for its first performance. At the animation’s heart, though, is this piece of clockwork with prime-number cogs controlling the harmonic and rhythmic structure of the piece. I have performed the animation with live music and have always been blown away by how the musicians can perfectly keep in sync with the clockwork, despite having their eyes glued to their musical scores.
Was Messiaen aware of the mathematical significance of these numbers? I asked composer George Benjamin, who worked with Messiaen in his later years, what mathematical training the composer had received. Benjamin thought he had essentially rediscovered the primes for himself. Playing around with numbers in his music had intuitively led him to this property: that primes can keep things out of step.
The power of primes to create discord has been taken up by more contemporary artists. Most Western pop music exploits the number 4. It is estimated that over 90 percent of all pop songs ever written are in 4/4 time. So prevalent is the role of 4 in building pop music that 4/4 time is often referred to as ‘common time’ and indicated simply by a large C written at the beginning of the music. One of the explanations is that pop songs are for dancing, and therefore even numbers work best for a species that dances on two feet. But some musicians enjoy disrupting those expectations.
Radiohead are probably the recent band that have most consistently used all these tricks of strange time signatures and rhythms. Their use of prime numbers to disrupt expectations is responsible, as much as anything, for the band’s unique and ground-breaking sound world. I defy you to listen to ‘Everything in Its Right Place’ and be able to count out what’s going on. The name of the song is rather ironic, given that nothing seems in its right place rhythmically. The shifting back and forth between five beats and four beats and six beats creates the strange, undulating sound that you can just sway to, as if blown in the wind, rather than dance to. ‘Paranoid Android’ does a similar thing, moving between eights and sevens, never allowing any one of the sequences to stabilise into a pattern, and giving the feeling every time you hear the seven beats that the music has glitched. It came as no surprise when I discovered that lead guitarist Jonny Greenwood, who composed much of Radiohead’s music, had, like me, fallen in love with Messiaen while playing in his local youth orchestra.