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.4-30

Exercise 1.2.4-30

proved in Lean solution written

RatingM30
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.4 of Volume 1. Companion chapter: Integer functions and elementary number theory

The task

Prove that φ\varphi is multiplicative, compute φ(1000000)\varphi(1000000), and give a rule for φ(n)\varphi(n) from the prime factors of nn.

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

Pair each kk in {0,…,rs−1}\{0, \ldots, rs - 1\} with the two remainders (k mod r,k mod s)(k \bmod r, k \bmod s).

Hint 2

Law D shows that this pairing is one-to-one when r⊥sr \perp s. Count the pairs in which both parts are relatively prime to their moduli.

Hint 3

Then use the values φ(pe)\varphi(p^e) of Exercise 1.2.4-27.

Solution

Show the solution

Plan. Step 1: k⊥rsk \perp rs if and only if k⊥rk \perp r and k⊥sk \perp s. Step 2: the pairing is a bijection between the set {0,…,rs−1}\{0, \ldots, rs - 1\} and the set of pairs {0,…,r−1}×{0,…,s−1}\{0, \ldots, r - 1\} \times \{0, \ldots, s - 1\}. Step 3: the pairing keeps the relatively prime property. Count.

Let r⊥sr \perp s, both positive.

Step 1. If k⊥rsk \perp rs, a common divisor of kk and rr divides rsrs, so gcd⁡(k,r)=1\gcd(k, r) = 1, and the same holds for ss. Conversely let k⊥rk \perp r and k⊥sk \perp s. If gcd⁡(k,rs)>1\gcd(k, rs) > 1, a prime pp divides kk and rsrs. By Euclid's lemma p∣rp \mid r or p∣sp \mid s, so pp is a common divisor of kk with rr or with ss. This is impossible.

Step 2. Map kk to (k mod r,k mod s)(k \bmod r, k \bmod s). If two numbers kk, k′k' in {0,…,rs−1}\{0, \ldots, rs - 1\} have the same image, then k≡k′k \equiv k' modulo rr and modulo ss. By Law D (Exercises 1.2.4-17 and 1.2.4-18), k≡k′(modrs)k \equiv k' \pmod{rs}. Both lie in [0,rs)[0, rs), so k=k′k = k'. The map is one-to-one. The two sets have rsrs elements each, so the map is onto.

Step 3. For each kk, gcd⁡(k,r)=gcd⁡(k mod r,r)\gcd(k, r) = \gcd(k \bmod r, r), since k=(k mod r)+rtk = (k \bmod r) + rt shows that a common divisor of kk and rr divides k mod rk \bmod r, and conversely. The same holds for ss. So by Step 1, k⊥rsk \perp rs if and only if its image (u,v)(u, v) has u⊥ru \perp r and v⊥sv \perp s.

Count. By Steps 2 and 3, the kk in {0,…,rs−1}\{0, \ldots, rs - 1\} with k⊥rsk \perp rs correspond one to one to the pairs (u,v)(u, v) with u∈{0,…,r−1}u \in \{0, \ldots, r-1\}, u⊥ru \perp r, and v∈{0,…,s−1}v \in \{0, \ldots, s-1\}, v⊥sv \perp s. There are φ(r)\varphi(r) choices for uu and φ(s)\varphi(s) for vv. So φ(rs)=φ(r)φ(s)\varphi(rs) = \varphi(r)\varphi(s). □\square

The value. 1000000=26⋅561000000 = 2^6 \cdot 5^6 and 26⊥562^6 \perp 5^6. By Exercise 1.2.4-27, φ(26)=26−25=32\varphi(2^6) = 2^6 - 2^5 = 32 and φ(56)=56−55=15625−3125=12500\varphi(5^6) = 5^6 - 5^5 = 15625 - 3125 = 12500. So φ(106)=32⋅12500=400000\varphi(10^6) = 32 \cdot 12500 = 400000.

The rule. Let n=p1e1⋯ptetn = p_1^{e_1} \cdots p_t^{e_t} with distinct primes pip_i and ei≥1e_i \ge 1. The factors pieip_i^{e_i} are pairwise relatively prime, and each is relatively prime to the product of the others. By induction on tt with the multiplicative property,

φ(n)=∏i=1tpiei−1(pi−1)=n∏i=1t(1−1pi),\varphi(n) = \prod_{i=1}^t p_i^{e_i - 1}(p_i - 1) = n \prod_{i=1}^t \Bigl(1 - \frac{1}{p_i}\Bigr),

and φ(1)=1\varphi(1) = 1 for the empty product.

Check

φ(12)=φ(4)φ(3)=2⋅2=4\varphi(12) = \varphi(4)\varphi(3) = 2 \cdot 2 = 4: the numbers 1,5,7,111, 5, 7, 11. By the rule, 12(1−12)(1−13)=412 (1 - \tfrac12)(1 - \tfrac13) = 4. A direct count by the gcd gives φ(1000000)=400000\varphi(1000000) = 400000, and the multiplicative property holds for all coprime pairs r,s<30r, s < 30 in a computer run.

Remarks

The pairing in Step 2 is the Chinese remainder theorem. The book's answer takes another route: it builds the numbers relatively prime to rsrs from those for rr and for ss. By Exercise 1.2.4-31 the sum ∑d∣nφ(d)\sum_{d \mid n} \varphi(d) is multiplicative, and it equals nn on prime powers, so it equals nn for every 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.