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.5-11

Exercise 1.2.5-11

proved in Lean solution written

RatingM15
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.5 of Volume 1. Companion chapter: Permutations and factorials

The task

Let nn have rr ones in its binary form. Show that the exponent of 22 in n!n! is exactly n−rn - r.

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

Use Legendre's rule, eq. (8), with p=2p = 2.

Hint 2

Write n=2e1+⋯+2ern = 2^{e_1} + \cdots + 2^{e_r}. Compute ⌊n/2k⌋\lfloor n/2^k \rfloor by dividing each power of two separately and dropping the fractions.

Solution

Show the solution

By eq. (8) the exponent of 22 in n!n! is μ=∑k≥1⌊n/2k⌋\mu = \sum_{k \ge 1} \lfloor n/2^k \rfloor. For each k≥1k \ge 1, the terms 2ei2^{e_i} with ei≥ke_i \ge k are multiples of 2k2^k, and the terms with ei<ke_i < k add up to less than 2k2^k, because they are distinct powers 2e2^{e} with e<ke < k and their sum is at most 2k−12^k - 1. Therefore

⌊n2k⌋=∑ei≥k2ei−k.\left\lfloor \frac{n}{2^k} \right\rfloor = \sum_{e_i \ge k} 2^{e_i - k}.

Sum over k≥1k \ge 1 and exchange the order of summation:

μ=∑i=1r∑k=1ei2ei−k=∑i=1r(2ei−1+⋯+2+1)=∑i=1r(2ei−1)=n−r.\mu = \sum_{i=1}^{r} \sum_{k=1}^{e_i} 2^{e_i - k} = \sum_{i=1}^{r} \left(2^{e_i - 1} + \cdots + 2 + 1\right) = \sum_{i=1}^{r} \left(2^{e_i} - 1\right) = n - r.

So 2n−r2^{n-r} divides n!n! and 2n−r+12^{n-r+1} does not, because μ\mu is the largest exponent.

Check

n=10=23+21n = 10 = 2^3 + 2^1 has r=2r = 2, and 10!=3628800=28⋅1417510! = 3628800 = 2^8 \cdot 14175 with 1417514175 odd. So the exponent is 8=10−28 = 10 - 2. For n=8=23n = 8 = 2^3, r=1r = 1 and 8!=40320=27⋅3158! = 40320 = 2^7 \cdot 315. Python checks all n≤300n \le 300.

Remarks

Exercise 1.2.5-12 is the same result for any prime pp in place of 22. The number n−rn - r is nn minus the number of ones in the binary form. In particular n!n! is odd only for n≤1n \le 1, and (2nn)\binom{2n}{n} has an exponent of 22 equal to the number of ones in nn.

This solution is checked, 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.