Primes and the Major Scale
The primes that organize long division are the same primes that organize musical pitch. In base 30, the alignment deficit lattice produces the just major scale. In base 12, the Pythagorean comma.
October 2020, revised April 2026
I have been a musician for most of my life. I have also spent most of my life hearing people claim that the golden ratio explains music. These claims always dissolve on contact with the mathematics. The golden ratio is not the frequency ratio of any interval in any standard tuning system. The Fibonacci sequence approximates the semitone layout but does not generate it. The popular accounts do not produce the scale.
The alignment deficit does produce the scale. Not approximately. Not by analogy. The deficit ratios on the smooth-integer lattice converge to the intervals of just intonation, and they do it because the primes that organize long division are the same primes that organize musical pitch.
The connection does not run through phi directly. Phi does not appear in any musical interval. But phi selects the prime 3, and the prime 3 generates the fifth, and the fifth generates the scale. After years of looking for the bridge between the golden ratio and music, it turns out to run through the digit function.
The deficit
The Tier 2 alignment from The Three-Tier Theorem approaches $2/3$ but never reaches it. The distance still to go is the deficit.
Look at the deficits for the pure powers of 2.
| $m$ | $n = 3m$ | deficit |
|---|---|---|
| 4 | 12 | 1/33 |
| 8 | 24 | 1/69 |
| 16 | 48 | 1/141 |
| 32 | 96 | 1/285 |
| 64 | 192 | 1/573 |
Each step doubles $m$ and approximately halves the deficit. Not exactly, but the ratio converges to 2 as $m$ grows. Doubling the smooth factor halves the remaining distance to the limit.
In music, each octave doubles the frequency.
That parallel is not a metaphor. The deficit is a rational function of $m$, and its ratio between two lattice points converges to the ratio of the points themselves. Doubling $m$ gives a ratio of 2. Tripling $m$ gives 3. Multiplying by 5 gives 5. The deficit inherits the multiplicative structure of the smooth integers.
The 10-smooth numbers live on a two-dimensional lattice. One axis is the prime 2. The other is the prime 5. Moving along the 2-axis halves the deficit. Moving along the 5-axis divides by 5. But there is no axis for the prime 3. The prime 3 governs the Tier 2 conductor ($n = 3m$), but it does not appear in the smooth lattice. It sits outside the coordinate system it created. The two roles are structurally distinct.
In music, the interval of the fifth is the ratio $3/2$. It is the most consonant interval after the octave, the structural backbone of harmony in every musical tradition that has one. To produce it on the deficit lattice, you need 3 as a smooth generator. In base 10, you do not have it. The lattice gives you octaves and powers of 5, but the single most important interval in music is not there.
The fifth is missing.
Base 12
Change the base and the lattice changes with it.
Base 12 has smooth generators 2 and 3. The deficit lattice has two axes. One for 2. One for 3. Doubling $m$ halves the deficit. Tripling $m$ thirds it.
The octave (ratio 2) and the twelfth (ratio 3, an octave plus a fifth). Every Pythagorean interval is a ratio of products of 2 and 3. And here they are, living on the axes of the deficit lattice. The octave is one step along the 2-axis. The fifth ($3/2$) is one step along the 3-axis and one step back along the 2-axis. The fourth ($4/3$) is two steps along the 2-axis and one step back along the 3-axis.
The deficit lattice in base 12 is the Pythagorean tuning lattice. Not by analogy. By arithmetic.
The comma
Twelve perfect fifths should equal seven octaves, but they do not. The discrepancy is
This small ratio, about a quarter of a semitone, is one of the oldest observations in all of mathematics. Philolaus wrote about the impossibility of dividing a whole tone into two equal halves in the fifth century BC. The Chinese mathematician Jing Fang computed the comma explicitly in 50 BC. Equal temperament was invented to distribute this error across all twelve keys, and for four hundred years Western music has lived inside that compromise.
531441 is twelve fifths. 524288 is seven octaves. The deficit ratio at those two lattice points is $1.013643$.
The Pythagorean comma. Matching to six significant figures at finite $m$. Exact in the limit.

The alignment formula reproduces the comma because the deficit ratio converges to the ratio of the lattice points, and 531441/524288 is the comma. The oldest tension in Western music is a theorem about repeating decimals.
The principle
The deficit ratio depends on the prime support of the base, not the base itself. Any base whose prime factors are 2 and 3 (base 6, 12, 24, ...) produces the same Pythagorean lattice. Any base whose prime factors include 2, 3, and 5 (base 30, 60, 120, ...) produces the same five-limit lattice. The base picks the specific prime $p$ and the rate of convergence. The lattice structure comes from the prime support alone.
The primes 2, 3, and 5 generate the intervals of the Western scale. The octave is 2. The fifth is $3/2$. The major third is $5/4$. Pythagoras knew the first two. The third took two thousand years. Ramos de Pareja proposed the just major third ($5/4$) in 1482, replacing the harsh Pythagorean 81/64. Zarlino codified it in 1558. The prime-axis lattice description of these intervals is classical and goes back at least to Euler. Archibald published the integer sequence 24:27:30:32:36:40:45:48 as the just major scale in the American Mathematical Monthly in 1924.
The lattice is Euler's. The intervals are Pythagoras's. The comma has been known for twenty-five centuries. Nobody had arrived at any of them through the alignment deficit of repeating decimals. That route, and the discovery that the deficit formula converges multiplicatively on the smooth lattice, recovering the major scale from long division in base 30, is what this program contributes.
Base 30 and the major scale
Base $30 = 2 \times 3 \times 5$.
These are the three primes of five-limit just intonation. They are also the three primes that the digit function has been selecting throughout this program. The golden ratio is $\varphi = (1 + \sqrt{5})/2$, built from 1, 2, and 5. The prime 3 is the one the golden ratio selects. The Unitum differentiates unity into these three modes simultaneously. Now, in the deficit lattice, 2, 3, and 5 produce the major scale.
The lattice is three-dimensional.
Start at $m_0 = 24 = 2^3 \times 3$. This is the least common denominator of the just scale ratios, the smallest smooth integer from which all seven notes can be reached by multiplying and dividing by 2, 3, and 5. The lattice points reachable within one octave include 27, 30, 32, 36, 40, 45, and 48. Their ratios to 24 are 9/8, 5/4, 4/3, 3/2, 5/3, 15/8, and 2.
Those are the just major scale intervals.
| Note | m | m/m₀ | Deficit ratio |
|---|---|---|---|
| Do | 24 | 1 | 1.000 |
| Re | 27 | 9/8 | 1.125 |
| Mi | 30 | 5/4 | 1.250 |
| Fa | 32 | 4/3 | 1.334 |
| Sol | 36 | 3/2 | 1.501 |
| La | 40 | 5/3 | 1.668 |
| Ti | 45 | 15/8 | 1.876 |
| Do | 48 | 2 | 2.001 |
Nobody asked for these intervals. The lattice produced them because the smooth integers within one octave of 24 happen to sit at exactly the ratios that Western music calls do re mi fa sol la ti do. 9/8 appears because $27/24 = 9/8$. 3/2 appears because $36/24 = 3/2$.
Watch the fifth lock in as $m_0$ grows.
| m₀ | Deficit ratio at 3/2 |
|---|---|
| 24 | 1.500719 |
| 240 | 1.500072 |
| 2400 | 1.500007 |
| 24000 | 1.5000007 |
| 240000 | 1.50000007 |
| 2400000 | 1.500000007 |
Each row gains a decimal place. The ratio converges to $3/2$ exactly. Not $3/2$ plus an error term that goes to zero. The limit is $3/2$. Every interval in the table does the same. The scale is exact in the limit.

The step pattern between consecutive notes is 9/8, 10/9, 16/15, 9/8, 10/9, 9/8, 16/15.
Whole tone. Whole tone. Semitone. Whole tone. Whole tone. Whole tone. Semitone.
That pattern is the major scale. Every major key in every instrument in every tradition that uses the Western tonal system follows it. And it falls out of the deficit lattice of long division in base 30 without being asked to.
Do re mi fa sol la ti do. From repeating decimals.
A road nobody took to a place that was already on the map.
Try it yourself
Eight notes, do to do, the full octave.
$ ./nfield scale
Just Major Scale (base 30, p = 29, m0 = 24)
Note m/m0 def.ratio lattice error
Do (C) 1/1 1.000000 1.000000 0.00e+00
Re (D) 9/8 1.125180 1.125000 1.60e-04
Mi (E) 5/4 1.250360 1.250000 2.88e-04
Fa (F) 4/3 1.333813 1.333333 3.60e-04
Sol (G) 3/2 1.500719 1.500000 4.80e-04
La (A) 5/3 1.667626 1.666667 5.76e-04
Ti (B) 15/8 1.876259 1.875000 6.71e-04
Do (C) 2/1 2.001439 2.000000 7.19e-04
Now all twelve tones, every sharp and flat between do and do.
$ ./nfield scale --chromatic
Just Chromatic Scale (base 30, p = 29, m0 = 480)
Note m/m0 def.ratio lattice error
C 1/1 1.000000 1.000000 0.00e+00
C# 16/15 1.066671 1.066667 4.49e-06
D 9/8 1.125009 1.125000 7.98e-06
Eb 6/5 1.200014 1.200000 1.20e-05
E 5/4 1.250018 1.250000 1.44e-05
F 4/3 1.333357 1.333333 1.80e-05
F# 45/32 1.406279 1.406250 2.08e-05
G 3/2 1.500036 1.500000 2.39e-05
Ab 8/5 1.600043 1.600000 2.69e-05
A 5/3 1.666715 1.666667 2.87e-05
Bb 9/5 1.800057 1.800000 3.19e-05
B 15/8 1.875063 1.875000 3.35e-05
C 2/1 2.000072 2.000000 3.59e-05
Code: github.com/alexspetty/nfield
Alexander S. Petty
October 2020 (revised April 2026)
.:.