taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.6-11

Exercise 1.2.6-11

proved in Lean solution written

RatingM20
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.6 of Volume 1. Companion chapter: Binomial coefficients

The task

Show that the exact power of a prime pp in (a+ba)\binom{a+b}{a} is the number of carries when aa and bb are added in base pp.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Count the exponent of pp in a factorial with Legendre's formula, as in Exercise 1.2.6-4.

Hint 2

Rewrite Legendre's formula with the digit sum s(m)s(m) of mm in base pp.

Hint 3

Compare s(a)+s(b)s(a) + s(b) with s(a+b)s(a+b) when carries happen. Each carry loses p−1p - 1 from the digit sum.

Solution

Show the solution

Let s(m)s(m) be the sum of the base pp digits of mm and v(m)v(m) the exponent of pp in m!m!.

Step 1: v(m)=(m−s(m))/(p−1)v(m) = (m - s(m))/(p-1). By Exercise 1.2.6-4, v(m)=∑i≥1⌊m/pi⌋v(m) = \sum_{i \ge 1} \lfloor m/p^i \rfloor. Write m=∑jdjpjm = \sum_j d_j p^j. Then ⌊m/pi⌋=∑j≥idjpj−i\lfloor m/p^i \rfloor = \sum_{j \ge i} d_j p^{j-i}, and summing over i≥1i \ge 1, v(m)=∑jdj∑i=1jpj−i=∑jdjpj−1p−1=m−s(m)p−1.v(m) = \sum_j d_j \sum_{i=1}^{j} p^{j-i} = \sum_j d_j \frac{p^j - 1}{p - 1} = \frac{m - s(m)}{p-1}.

Step 2: the exponent of pp in the coefficient. It is v(a+b)−v(a)−v(b)=s(a)+s(b)−s(a+b)p−1.v(a+b) - v(a) - v(b) = \frac{s(a) + s(b) - s(a+b)}{p-1}.

Step 3: carries and the digit sum. Let ai,bia_i, b_i be the digits of a,ba, b, and let ci∈{0,1}c_i \in \{0, 1\} be the carry out of position ii, with c−1=0c_{-1} = 0. The column rule of addition says ai+bi+ci−1=di+p cia_i + b_i + c_{i-1} = d_i + p\,c_i, where did_i is the digit of a+ba + b at position ii. Add these equations over all ii: s(a)+s(b)+∑ici−1=s(a+b)+p∑ici.s(a) + s(b) + \sum_i c_{i-1} = s(a+b) + p \sum_i c_i. The sum of ci−1c_{i-1} over i≥0i \ge 0 equals the sum of cic_i over i≥0i \ge 0, since c−1=0c_{-1} = 0. Call this common value CC, the number of carries. Then s(a)+s(b)−s(a+b)=(p−1) Cs(a) + s(b) - s(a+b) = (p-1)\,C.

Step 4. By Step 2 the exponent of pp in (a+ba)\binom{a+b}{a} is CC, the number of carries.

The form of the carry. The carry out of position ii is 11 exactly when the numbers formed by the lowest i+1i+1 digits, which are a mod pi+1a \bmod p^{i+1} and b mod pi+1b \bmod p^{i+1}, have a sum of at least pi+1p^{i+1}. This is the criterion of the formal statement. Beyond the position of the highest digit of a+ba+b there are no carries, so the count is finite.

Check

Take p=2p = 2, a=3a = 3, b=1b = 1. In binary 11+0111 + 01 gives carries out of positions 00 and 11, that is 22 carries. And (43)=4=22\binom{4}{3} = 4 = 2^2. Take p=3p = 3, a=4a = 4, b=5b = 5: 113+123=100311_3 + 12_3 = 100_3 has two carries, and (94)=126=2⋅32⋅7\binom{9}{4} = 126 = 2 \cdot 3^2 \cdot 7 has 323^2.

Remarks

The case of exponent zero says that pp does not divide (a+ba)\binom{a+b}{a} exactly when the addition has no carry, which agrees with Lucas's rule in Exercise 1.2.6-10. For p=2p = 2 it gives Exercise 1.2.6-12 again. The theorem is due to Kummer (1852).

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.