Dynamics

Fourteen fractions that list the primes

Change the Collatz rule so that the multiplier depends on the remainder modulo some other number than two, and the resulting maps can compute anything a computer can. John Conway proved it in 1972, which means no method can decide, for every such map, whether its orbits come down — and fourteen fractions, applied in order, turn out to be enough to print every prime.

Worth reading first: Where the Collatz map is a coin · The question nobody can answer.

The Collatz rule looks at one thing about a number — whether it is even or odd — and chooses one of two affine maps accordingly. The first essay on it mentioned in a single paragraph that the obvious generalisation is not merely hard but impossible: John Conway showed in 1972 that for rules which look at the remainder modulo some fixed number, and multiply and add accordingly, no algorithm can decide in general whether the orbits reach 1.

This essay unpacks that paragraph. The way Conway proved it is by showing that these maps can compute — that a suitably chosen rule of the Collatz kind is a computer — and the most vivid demonstration is a list of fourteen fractions that, applied by a rule of one sentence, produces the prime numbers in order.

The result changes what kind of problem the Collatz conjecture is. Before Conway it was possible to hope that some general theory of maps like 3n+13n + 1 — a theory of affine rules on remainders — would settle it along with all its relatives. After him, no such theory can exist, because some relatives are computers, and a theory that decided all of them would decide the halting problem. Whatever proves the Collatz conjecture, if anything does, must exploit something that distinguishes this one rule from the rules that compute.

PRIMEGAME: fourteen fractions whose powers of two are the primes. The size in binary digits of the numbers produced by Conway's PRIMEGAME from 2 over 40000 steps, with the pure powers of two marked; their exponents are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.
Fig. 1 Conway’s PRIMEGAME run from 2 for 40,000 steps: at each step the number is multiplied by the first of fourteen fractions that gives a whole number. The curve is its size in binary digits. Now and then it is an exact power of two, marked, and the exponents are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.

A rule that looks at more than the last digit

A generalised Collatz map fixes a modulus mm and, for each remainder rr from 00 to m−1m - 1, a rational number ara_r and another brb_r; it sends nn to arn+bra_r n + b_r when nn leaves remainder rr on division by mm. The numbers are chosen so that the result is always a whole number. The Collatz map is the case m=2m = 2: remainder 00 gives n/2n/2, remainder 11 gives (3n+1)/2(3n + 1)/2.

Nothing about the definition suggests anything more than more of the same — a larger table of affine pieces — and for small moduli that is roughly what they look like: orbits that wander, fall into cycles, or grow, with no visible structure. Conway’s observation was that a table of affine pieces can be arranged to do bookkeeping. With a large enough modulus, a single number can hold the contents of several counters at once, and the remainder can say which counter is to be changed next.

The cleanest way to see this is in a notation Conway published in 1987, in which the whole map is a list of fractions.

FRACTRAN: a program is a list of fractions

A FRACTRAN program is a finite list of positive fractions f1,f2,…,fkf_1, f_2, \ldots, f_k. To run it on a whole number nn, find the first fraction fif_i in the list for which nfin f_i is a whole number, and replace nn by nfin f_i. Repeat. If no fraction works, stop.

That is a generalised Collatz map. Whether nfin f_i is a whole number depends only on the remainder of nn modulo the denominators of the fractions, so the choice of fraction — and therefore the map — is decided by the remainder of nn modulo the least common multiple of all the denominators. The whole program is one row of multiplications, indexed by remainders.

What makes the notation readable is prime factorisation. Write n=2e23e35e5⋯n = 2^{e_2} 3^{e_3} 5^{e_5} \cdots and think of each exponent as a register holding a whole number. Multiplying by a fraction adds to the registers of the numerator’s primes and subtracts from the registers of the denominator’s primes, and “nfin f_i is a whole number” means exactly that the registers being subtracted from are large enough. A fraction is an instruction: if registers 7 and 11 are both non-zero, take one from each and add one to register 2.

A machine that multiplies

The six fractions 455/33455/33, 11/1311/13, 1/111/11, 3/73/7, 11/211/2, 1/31/3 multiply two numbers. Start with 2a3b2^a 3^b — the two inputs in registers 2 and 3 — and the program halts at 5ab5^{ab}.

A FRACTRAN program multiplying 3 by 4, register by register. A grid of the exponents of 2, 3, 5, 7, 11 and 13 over the 46 steps of Conway's multiplication program run on 2^3 · 3^4, ending with 5^12.
Fig. 2 Conway’s multiplication program run on 23⋅342^3 \cdot 3^4, drawn as registers: one row for each prime’s exponent, one column for each step, darker for larger values. The register of 2 is emptied one unit at a time; each time, the register of 3 is copied into the register of 5, with 7 holding a spare copy; after 46 steps the program halts at 5 to the twelfth.

Written out as numbers, the first steps look like nothing at all. The program starts at 648=23⋅34648 = 2^3 \cdot 3^4. No fraction but 11/211/2 gives a whole number, so the next number is 3564=22⋅34⋅113564 = 2^2 \cdot 3^4 \cdot 11. Now 455/33455/33 applies, giving 49140=22⋅33⋅5⋅7⋅1349140 = 2^2 \cdot 3^3 \cdot 5 \cdot 7 \cdot 13; then 11/1311/13 gives 4158041580; then 455/33455/33 again gives 573300=22⋅32⋅52⋅72⋅13573300 = 2^2 \cdot 3^2 \cdot 5^2 \cdot 7^2 \cdot 13. As a sequence of whole numbers — 648,3564,49140,41580,573300,…648, 3564, 49140, 41580, 573300, \ldots — it is as opaque as a Collatz orbit. Factored, it is a loop moving units from one register to two others, one at a time.

That contrast is the heart of the matter. A generalised Collatz map is a rule about remainders and multiplication, and on the face of it the numbers it produces are just numbers. The computation is visible only in a coordinate system — prime exponents — that the rule never mentions. Nothing forbids the ordinary Collatz orbits from carrying hidden bookkeeping of the same kind in some other coordinate system; nobody has found one, and nobody can rule it out.

Reading the grid shows how a list of fractions becomes an algorithm. The factor 455/33=(5⋅7⋅13)/(3⋅11)455/33 = (5 \cdot 7 \cdot 13)/(3 \cdot 11) is the inner loop: while registers 3 and 11 are both non-zero, it moves one unit from register 3 into registers 5 and 7, and flips a control register from 11 to 13; 11/1311/13 flips it back. When register 3 runs out, 1/111/11 clears the control flag, and 3/73/7 pours register 7 back into register 3 — restoring the second input. Then 11/211/2 takes one from register 2 and restarts the loop. The primes 11 and 13 are not data at all; they are the program’s state, the line of code it is on.

That is the whole idea behind the universality proof. A machine with a handful of counters, each of which can be incremented, decremented, and tested for zero, can compute anything a computer can — Marvin Minsky showed in the 1960s that two counters are already enough, given a suitable encoding. Every such machine translates into a FRACTRAN program by giving each counter a prime and each state a prime, and every FRACTRAN program is a generalised Collatz map.

The primes, from fourteen fractions

Conway’s PRIMEGAME is the fourteen fractions

1791,7885,1951,2338,2933,7729,9523,7719,117,1113,1311,1514,152,551.\tfrac{17}{91}, \tfrac{78}{85}, \tfrac{19}{51}, \tfrac{23}{38}, \tfrac{29}{33}, \tfrac{77}{29}, \tfrac{95}{23}, \tfrac{77}{19}, \tfrac{1}{17}, \tfrac{11}{13}, \tfrac{13}{11}, \tfrac{15}{14}, \tfrac{15}{2}, \tfrac{55}{1}.

Run it from 22. The numbers it produces grow and shrink erratically, and every so often one of them is a pure power of two. The exponents of those powers of two are exactly the prime numbers, in order, and no power of two with a composite exponent ever appears.

PRIMEGAME: fourteen fractions whose powers of two are the primes. The size in binary digits of the numbers produced by Conway's PRIMEGAME from 2 over 1000 steps, with the pure powers of two marked; their exponents are 2, 3, 5, 7.
Fig. 3 The first thousand steps of the same run. The powers 222^2, 232^3, 252^5 and 272^7 appear at steps 19, 69, 280 and 707; between them the number climbs to dozens of binary digits while the program tests the next candidate for divisibility.

Inside, PRIMEGAME is a machine testing each whole number nn in turn for divisibility by every smaller number, by repeated subtraction — the sieve’s question answered the slowest way possible. The registers of 2, 3, 5 and 7 hold the candidate, the trial divisor and working copies; the primes 11 to 29 are its states. When a candidate survives every trial division, the machine clears all its working registers except the one holding the candidate, and that is the moment the number is a pure power of two. The step counts grow fast — the tenth prime, 29, arrives after more than 36,000 steps — because every trial division is carried out by counting down one unit at a time.

The run in the opening figure checks what the program claims, prime by prime, for ten primes. It proves nothing about the eleventh. That PRIMEGAME lists every prime is a theorem about what its fourteen fractions compute, proved by reading them as a program, and a simulation can only illustrate it. Richard Guy, who popularised the program, described the proof as exactly that reading: identify which primes are states and which are registers, and check each fraction does what its line of the program should.

Why this makes the general question undecidable

Put the pieces together. Any computer program can be written as a counter machine; any counter machine as a FRACTRAN program; any FRACTRAN program as a generalised Collatz map. A program halts exactly when the map reaches a number that no fraction applies to — and a small change turns “stops” into “reaches 1”. So a method that decided, for every generalised Collatz map and every starting number, whether the orbit reaches 1 would decide whether every program halts. The diagonal argument shows that nothing can decide that.

Conway’s theorem is therefore that the generalised Collatz problem is undecidable: there is no algorithm that takes a map of this kind and a starting number and correctly says whether the orbit reaches 1. Stuart Kurtz and Janos Simon sharpened it in 2007: the question of whether every starting number reaches 1, for a given map, sits exactly at the level of logical complexity of statements of the form “for every input there is a halting computation” — as hard as questions of that shape can be.

It is the same phenomenon as the cellular automaton that computes: a rule too simple to look like a computer turns out to be one, and the undecidability of the general question is inherited from computation itself. And it is worth being exact about what it says. It does not say the ordinary Collatz problem is undecidable. That is one particular map with modulus two, and a single yes-or-no question about a single map is always decidable in the trivial sense that one of the two programs “print yes” and “print no” is correct. What Conway’s theorem says is that no general method for the family exists — so any proof of the Collatz conjecture must use something special about 3n+13n + 1 that fails for the maps that compute.

When a small machine meets a Collatz question

The connection runs in the other direction too, and recently it has become concrete. The busy beaver problem asks, for each number of states, how long a Turing machine with that many states can run before halting, starting on a blank tape — the fastest-growing function a computer can be made to define, and a cousin of the growth rates that ordinals measure. To know its value for five states, every five-state machine that does not obviously halt or obviously loop has to be analysed by hand or by proof assistant, and a large online collaboration completed that in 2024: the answer is 47,176,870 steps.

Along the way, some of the hardest machines to classify turned out to be running Collatz-like maps. Their tapes, read in the right way, hold a single number, and each pass of the head applies a rule of the form “multiply by three and halve, or halve, according to the remainder” — a generalised Collatz map with a tiny modulus, encoded in a handful of states. For six states the obstruction is sharper still: among the six-state machines is one whose halting is equivalent to a question about the orbit of a specific number under a Collatz-like map, a question with the same flavour as the orbit of 8 and no better prospects of an answer.

So the smallest machines that are hard to understand are hard for a Collatz reason, and the simplest Collatz-like maps may be hard for a computing reason. Conway’s theorem is the formal link between the two, and the busy beaver search is where it has stopped being formal.

A permutation that nobody can finish

Conway’s 1972 paper also contains a map that is not a computer, as far as anyone knows, and is not understood either. Send an even nn to 3n/23n/2; send nn with remainder 11 on division by four to (3n+1)/4(3n + 1)/4; send nn with remainder 33 to (3n−1)/4(3n - 1)/4. This is a generalised Collatz map with modulus four, and unlike the Collatz map it is a permutation: every whole number is sent somewhere and is reached from exactly one number, so every orbit runs backwards as well as forwards.

The small cycles of Conway's amusical permutation. The 4 cycles of Conway's permutation through numbers up to 2000: (1), (2 3), (4 6 9 7 5), (44 66 99 74 111 83 62 93 70 105 79 59).
Fig. 4 Every cycle of the permutation through a number up to 2,000: the fixed point 1, the swap of 2 and 3, a cycle of five through 4, 6, 9, 7, 5, and a cycle of twelve beginning at 44. Every other number up to 60 has an orbit that did not close within 400 steps.

It has a few short cycles, found by following each small number until it returns. Conway called it amusical because a step of 3/23/2 is a musical fifth and a step of 3/43/4 a fourth, and the map wanders up and down by fifths and fourths.

Conway's amusical permutation: the orbit of 8, forwards and backwards. The base-2 size of the orbit of 8 under Conway's permutation n ↦ 3n/2, (3n ± 1)/4, for 600 steps forwards and backwards, rising irregularly in both directions without repeating.
Fig. 5 The orbit of 8 under the permutation, six hundred steps forwards and six hundred backwards, measured in binary digits. It rises irregularly in both directions and never meets a number it has already visited. Whether it ever does — whether 8 lies on a cycle — is unknown.

The orbit of 8 is the famous one. Forwards it goes 8,12,18,27,20,30,45,34,51,38,57,43,32,…8, 12, 18, 27, 20, 30, 45, 34, 51, 38, 57, 43, 32, \ldots and backwards 8,11,15,10,13,…8, 11, 15, 10, 13, \ldots, and it has been followed for enormous numbers of steps in both directions without closing. A heuristic like the one that cannot be a proof predicts that it should not close: on average a step multiplies by about 3/23/2 half the time and 3/43/4 the other half, a net factor of 9/8>1\sqrt{9/8} > 1 forwards, so the orbit should drift upward and escape. Nobody can prove it. The question “is the orbit of 8 infinite?” is as simple to state as the Collatz problem and as far from being settled. The cycles it does have are constrained in the same way the Collatz cycles are, and the same argument applies: a cycle with aa steps of 3/23/2 and bb steps of 3/43/4 must bring the product of its factors back to one, up to the small additive corrections, which forces a relation between powers of two and three — the equation that bounds how short a Collatz cycle could be — and rules out cycles of many lengths without ruling out the orbit of 8 closing at some enormous one.

What the machines cannot show

Every figure runs a program for finitely many steps. The PRIMEGAME figure shows ten primes; the multiplication figure one product; the permutation figure twelve hundred steps of one orbit. None of them shows the thing the essay is about, which is a statement about all programs, and undecidability in particular has no picture: it says a certain method does not exist, and a figure can only show methods that do.

The pictures also hide how the encodings work in detail. PRIMEGAME’s fourteen fractions implement a program that a person can read, with effort, and the universality construction implements any program, but the translation from a counter machine to fractions involves bookkeeping that a picture of registers flashes past in a few dozen columns. Reading the grid as an algorithm, as above, is the most the figure can support. And the heuristics quoted for the permutation are exactly that. The average multiplier per step predicts drift; it does not account for the correlations between successive remainders, which are what a map that computes would exploit, and nothing in a plot of twelve hundred steps can tell a drifting orbit from one that will turn round after a million.

Still open: the orbit of 8, and which simple maps compute

The general question is closed — undecidable — and the particular ones are open. Whether the Collatz map itself sends every number to 1 is unknown; whether the amusical permutation’s orbit of 8 is infinite is unknown; whether the 5n+15n + 1 map, which behaves like a coin tilted toward growth, has any orbit that grows for ever is unknown.

Between the general theorem and the particular questions sits a question about thresholds: how small can the modulus, or the number of fractions, be for a map of this kind to be universal? Constructions with fairly small moduli are known, and it is known that some very small maps are not universal, but the boundary is not located — and whether the Collatz map itself lies on the computing side of it, which would make its individual orbits as unpredictable as programs, is not known either. What is known is that the modulus-two case is special in one clean respect: on the 2-adic integers it is exactly a coin, with no room in its dynamics for the bookkeeping a computer needs — a hint, and no more than a hint, that it lies on the simple side.