Discrete

The carries decide the divisibility

How many times a prime divides a binomial coefficient is not a fact about the coefficient at all. It is a count of the carries that happen when two numbers are added in that prime's base, which is a question about column addition and has nothing to do with choosing anything.

Worth reading first: Pascal's triangle, in two colours · Every entry counts the routes to it.

The rung below shaded the odd entries of Pascal’s triangle and found the Sierpiński triangle, and explained it with Lucas’ theorem: an entry is odd exactly when the binary digits of kk sit under those of nn. That settles which entries are divisible by two and says nothing about how often.

Kummer’s answer, from 1852, is startling on first reading and has nothing to do with choosing.

3 carries in base 2, and 2 divides it 3 times. The addition of 5 and 7 written in base 2, column by column, with the carries marked. There are 3, and 2 divides the binomial coefficient 792 exactly 3 times.
Fig. 1 Five plus seven, in binary, column by column. Three columns produce a carry, and two divides (125)=792\binom{12}{5} = 792 exactly three times. The figure computes the exponent independently — by Legendre’s count of the multiples of two in the three factorials — and requires the two to agree, and then divides the coefficient by two three times to check that nothing is left.

The exponent of pp in (nk)\binom{n}{k} is the number of carries when kk and nkn-k are added in base pp. That is a statement about the mechanics of column addition, and it is exactly equal to a statement about divisibility — a question about what a number’s divisors look like answered by looking at how two other numbers are written.

Why a carry is a divisibility

The proof is a comparison of two counts and it is short enough to give.

Legendre’s formula says the exponent of pp in m!m! is

mp+mp2+mp3+,\left\lfloor \frac{m}{p}\right\rfloor + \left\lfloor \frac{m}{p^2}\right\rfloor + \left\lfloor \frac{m}{p^3}\right\rfloor + \cdots,

because the first term counts the multiples of pp up to mm, the second counts those divisible by p2p^2 a second time, and so on. So the exponent in (nk)=n!/(k!(nk)!)\binom{n}{k} = n!/(k!\,(n-k)!) is the alternating combination of three such sums.

Now the digits. Write sp(m)s_p(m) for the sum of the base-pp digits of mm. Legendre’s formula collapses to

exponent of p in m!=msp(m)p1,\text{exponent of } p \text{ in } m! = \frac{m - s_p(m)}{p-1},

which is a rearrangement rather than a new idea: each digit of mm contributes to the floors below it in a pattern that adds up exactly that way.

Substituting,

exponent in (nk)=sp(k)+sp(nk)sp(n)p1.\text{exponent in } \binom{n}{k} = \frac{s_p(k) + s_p(n-k) - s_p(n)}{p-1}.

And there is the carry. Adding kk and nkn-k digit by digit, each carry replaces a digit sum of pp or more by a digit pp less and adds one to the column above — so each carry reduces the total digit sum by exactly p1p-1. The numerator counts the total loss and the division by p1p-1 turns it into a count of carries.

That is the whole argument, and the pleasing part is which step is doing the work. Legendre’s formula is about multiples; the digit-sum form is about place value; and the bridge between them is that dividing by pp and taking a floor is the same as dropping a digit.

The two extremes

6 carries in base 2, and 2 divides it 6 times. The addition of 37 and 63 written in base 2, column by column, with the carries marked. There are 6, and 2 divides the binomial coefficient 3420029547493938143902737600 exactly 6 times.
Fig. 2 A larger case in binary: six carries, so two divides (10037)\binom{100}{37} exactly six times. The coefficient is a twenty-nine-digit number, and the figure computes it in exact whole-number arithmetic — a double-precision value of it is wrong in the digits that decide divisibility, which is exactly the question being asked.

No carries at all means the exponent is nought, which means the entry is not divisible by pp. Adding kk and nkn-k without a carry means every column sums to less than pp, which for p=2p = 2 means kk and nkn-k never have a one in the same place — which means the binary digits of kk sit under those of nn. That is Lucas’ theorem, recovered as the case of no carries.

So the rung below’s fractal is the exponent-zero level set of the picture on this page. The Sierpiński triangle is where no carry happens, and everything shaded there is where at least one does.

Every column carrying is the other extreme and gives the largest exponent available. The largest is bounded: a carry can only happen in a column, and nn has about logpn\log_p n of them, so the exponent of pp in any entry of row nn is at most logpn\log_p n. A binomial coefficient of a hundred digits is divisible by two at most seven times, which is a much stronger statement than the size of the number suggests and follows from nothing but the column count.

2 carries in base 5, and 5 divides it 2 times. The addition of 37 and 63 written in base 5, column by column, with the carries marked. There are 2, and 5 divides the binomial coefficient 3420029547493938143902737600 exactly 2 times.
Fig. 3 The same pair in base five. Two carries, so five divides the coefficient twice. The carries are in different places and there are fewer of them, which is the general pattern: a larger base has fewer columns and each is harder to overflow.

The whole triangle at once

Computing the exponent at every entry of a triangle gives a picture, and the picture is a refinement of the rung below’s.

How often 2 divides each entry, for 27 rows. Pascal's triangle for 27 rows, each entry shaded by how many times 2 divides it — nought left blank, and up to 4 elsewhere. The exponent is computed two independent ways at every entry.
Fig. 4 Twenty-seven rows shaded by how many times two divides each entry: blank for nought, then successively darker. The blank cells are the Sierpiński triangle exactly, and the darker regions are self-similar copies of the same shape at smaller scales.

The blank region is the parity fractal, and the shaded regions are organised the same way, because the count of carries is a digit-by-digit statement and digits are a self-similar structure. The whole picture is a stack of Sierpiński triangles, one for each exponent, and the rung below’s figure is the top layer.

How often 3 divides each entry, for 27 rows. Pascal's triangle for 27 rows, each entry shaded by how many times 3 divides it — nought left blank, and up to 2 elsewhere. The exponent is computed two independent ways at every entry.
Fig. 5 The same measurement in base three. The blocks are threes rather than twos, the self-similarity is at a scale of three, and the blank region is the modulo-three pattern the rung below drew — again as the case of no carries.

That the two pictures differ only in their block size is the content of Kummer’s theorem restated visually. Nothing about the arithmetic changes with pp; what changes is how many digits a number has and how easily a column overflows.

The self-similarity has an exact statement worth having, because it is the reason the pictures repeat rather than merely resembling themselves. Adding a new leading digit to nn adds a column that the addition of kk and nkn-k may or may not carry out of, and whether it does depends only on that column and on the carry arriving from below. So the picture for rows 00 to pm+1p^{m+1} is built from pp blocks each of which is the picture for rows 00 to pmp^m, with the exponent raised by one in the blocks where the new column carries.

That is a construction rule for the whole family, and it says the shading is not approximately self-similar but exactly so, at every scale, with the deeper shades appearing precisely where a higher column carries. A fractal that is drawn by a rule about place value has no approximation in it at all, which distinguishes these pictures from the attractors of a dynamical system that look the same and are not.

Why the exponent is small, and why that matters

The bound of logpn\log_p n deserves a second look, because it says something about binomial coefficients that is not obvious from any other description.

(10050)\binom{100}{50} is about 102910^{29}. Its prime factorisation contains only primes up to 100100 — there are twenty-five of them — and each appears at most logp100\log_p 100 times, which is seven for p=2p = 2 and one for every prime above 1010. So a number of twenty-nine digits is a product of twenty-five small primes with small exponents.

A binomial coefficient is enormous and its factorisation is short, and that is the reason so many arguments about primes go through them.

The sharpest consequence is a fact about the primes between nn and 2n2n. Take pp in that range and ask how often it divides (2nn)\binom{2n}{n}: adding nn and nn in base pp, the number nn is a single digit — since p>np > n — and the column sums to 2n2n, which is at least pp, so there is exactly one carry. Every prime strictly between nn and 2n2n divides the central coefficient exactly once, and none divides it twice.

That single sentence is most of a proof that such a prime exists. The coefficient is at least 4n/(2n+1)4^n/(2n+1), which is large; every prime factor is at most 2n2n; the ones below 2n\sqrt{2n} can contribute at most 2n2n each by the logarithm bound; and the ones between 2n/32n/3 and nn contribute nothing at all, by a second carry count. If no prime lay between nn and 2n2n the remaining factors could not account for the size, and there is always one.

Every step of that is a carry count. The theorem on this page is not an ingredient of the argument; it is the argument, with the size bound supplying the contradiction. Erdős’ proof of Bertrand’s postulate — that there is always a prime between nn and 2n2n — works by bounding (2nn)\binom{2n}{n} from below by its size and from above by its factorisation, and the upper bound is exactly Kummer’s theorem doing the work.

The same shape of argument runs through most elementary results about the distribution of primes. The coefficient is big; its prime factors are constrained; therefore there must be enough of them; therefore primes exist where they were claimed to. The size and the factorisation are two independent handles on one number, and Kummer’s theorem is what makes the second one exact.

What it costs to answer

The two computations the figures run cost very different amounts, and the difference is the practical value of the theorem.

By Legendre’s formula, the exponent of pp in (nk)\binom{n}{k} is a sum of about logpn\log_p n floors for each of three factorials — thirty operations for nn in the hundreds, and it never forms the coefficient.

By counting carries, it is one pass of column addition over logpn\log_p n columns, which is the same order and slightly cheaper.

By computing the coefficient and dividing, it is a multiplication and a division for each of kk steps to build a number with nn digits in it, and then repeated division. For (1000500)\binom{1000}{500} that is a number with two hundred and ninety-nine digits, and every operation on it costs proportionally.

So the theorem turns a question about an enormous number into a question about its inputs’ digits, and the saving is not marginal — it is the difference between arithmetic on nn digits and arithmetic on logn\log n of them. The exponent was never a property that needed the number, which is a common shape: a quantity defined in terms of an object often depends on far less of the object than its definition suggests.

That is also the reason the two computations are worth running against each other in a figure rather than trusting one. They share no step: one is a sum of floors, the other is a carry count, and the only thing connecting them is the theorem. Two implementations of a theorem agreeing is evidence the theorem was implemented; one implementation agreeing with itself is evidence of nothing.

What happens between the primes

The picture for a single prime is a stack of self-similar layers, and a natural question is what the entry looks like when every prime is taken into account at once.

The answer is that the pictures are independent. The exponent of two and the exponent of three are computed from different digit expansions of the same pair of numbers, and there is no relation between them — a row can have entries divisible by two many times and by three not at all, and the two shaded triangles for the same rows look nothing alike beyond both being self-similar.

That independence has a consequence for the composite case. The behaviour of a coefficient modulo six is determined by its behaviour modulo two and modulo three together, so the modulo-six picture is the superposition of two self-similar patterns with different block sizes — and a superposition of a two-scale pattern and a three-scale one is self-similar at scale six, but with a period that takes six times as many rows to become visible.

So the composite pictures are not messier because something breaks; they are messier because two independent structures are being seen at once. Lucas’ theorem fails for a composite modulus for the same reason: it is a statement about one base, and a composite modulus corresponds to no single base.

The general principle is worth keeping. A question about divisibility by a composite number is a question about each of its prime powers separately, and the pictures obey that decomposition exactly. What is lost in going to a composite is not structure but the ability to see the structure in one picture.

Where it needs its hypotheses

The base must be prime. Legendre’s formula counts multiples of pp, p2p^2 and so on, and the count is right only because a prime power’s contribution is a simple floor. For a composite modulus the digit argument survives and the divisibility statement does not, which is why the rung below’s modulo-three and modulo-five pictures are self-similar and a modulo-six one is messier.

The exponent is about pp and not about a prime power. A prime is the atom of divisibility and this theorem is about one atom at a time. Kummer’s theorem gives the exact power of pp dividing the entry; the entry’s behaviour modulo p2p^2 is a further question with a further answer (Granville’s extension of Lucas’ theorem), and it is considerably less tidy.

The carries depend on the pair, not on nn alone. Two entries of the same row can have completely different exponents, and the picture makes that visible — a row of the shaded triangle is generally not uniform in colour.

And the coefficient has to be computed exactly. This is the one hypothesis about the figure rather than the mathematics, and it caught a version of it: (10037)\binom{100}{37} has twenty-nine digits, a double-precision number carries sixteen, and dividing a rounded value by two six times to check that six is the right exponent gives a residue that means nothing. The figures compute the coefficient in exact whole numbers for that reason.

Kummer, and what he was doing

Ernst Kummer proved this in 1852, and he was not investigating Pascal’s triangle. He was working on Fermat’s last theorem, and specifically on the failure of unique factorisation in the rings of cyclotomic integers — the failure he repaired by inventing ideal numbers, which is the origin of the modern notion of an ideal.

Binomial coefficients turn up in that work because the exponents of primes dividing them control the divisibility of certain sums, and the carry criterion was the tool he needed rather than the result he was after. It is now the more famous of the two, which is the usual fate of a clean lemma inside a difficult programme — the Lagrange remainder is the same story in analysis.

Lucas proved his own theorem in 1878, twenty-six years later, and it is the special case. The order is worth knowing because it is the opposite of the order they are usually taught: the general statement came first, was forgotten outside a specialist literature, and the special case was rediscovered and became the famous one.

What the pictures cannot show

The column-addition figure shows one pair of numbers in one base, and the theorem is about every nn, every kk and every prime. The shaded triangles check every entry of twenty-seven rows — three hundred and seventy-eight of them, both ways — which is a lot of instances and no proof.

The shaded pictures also cannot show the exponent past the fifth, since there are only so many distinguishable shades, and the deepest cells in a large triangle would need more. The figures use a small enough triangle that the range fits.

And nothing here draws the connection the essay is mostly about. That the blank cells of the shaded triangle are the rung below’s fractal is a statement about two pictures, and the two are drawn on the same page and never superimposed — because a superposition would be a picture with one region shaded two ways, which says less than either.

The ladder from here

Rungs above: Granville’s extension, which computes the coefficient modulo p2p^2 and p3p^3 and needs a correction term the digit argument does not supply. The composite moduli, where the pattern is messier and more interesting and Lucas’ theorem simply fails. The Chinese remainder assembly of those pictures, which recovers the composite case from the prime ones. Erdős’ proof of Bertrand’s postulate in full, where this theorem is the load-bearing bound. And the exponent’s average behaviour over a row, which is a question about digit sums and has an answer with a logarithm in it.

A question about numbers, answered by their notation

The habit is the one worth arguing with, because it looks like a violation of a rule this collection otherwise keeps.

Divisibility is a property of a number and not of how it is written. A number divisible by three stays divisible by three in every base, and any criterion phrased in terms of digits is phrased in terms of a representation that the property does not depend on.

And yet the answer here is a fact about column addition in a particular base. The resolution is that the base is the prime, and base-pp notation is not an arbitrary choice for a question about pp — it is the notation in which the multiples of pp, of p2p^2 and so on are visible as trailing zeros. Writing a number in base pp is exactly the act of separating out the powers of pp it contains.

So the rule survives, sharpened: a criterion in terms of digits is suspicious unless the base is chosen by the question. The divisibility-by-nine test in base ten is the same phenomenon and it is usually presented as a trick, when it is the statement that ten is one more than nine and so every power of ten is one more than a multiple of nine. Choose the base to suit the divisor and the digits stop being notation and start being the decomposition the question was about.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Binomial coefficientDivisibilityKummer's theoremLucas' theoremParityPlace valuePrimesSelf-similarity