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-27

Exercise 1.2.4-27

proved in Lean solution written

RatingM15
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

Count the integers in {0,1,…,n−1}\{0, 1, \ldots, n-1\} that are relatively prime to nn when nn is a prime pp and when n=pen = p^e.

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

Decide which kk with 0≤k<pe0 \le k < p^e have a common divisor greater than 11 with pep^e.

Hint 2

Only the prime pp can divide both. Count the multiples of pp.

Solution

Show the solution

Let 0≤k<pe0 \le k < p^e. Claim: k⊥pek \perp p^e if and only if p∤kp \nmid k. If p∣kp \mid k, then pp is a common divisor greater than 11. If p∤kp \nmid k and gcd⁡(k,pe)>1\gcd(k, p^e) > 1, then some prime qq divides both kk and pep^e. By Euclid's lemma, q∣pq \mid p, so q=pq = p, which contradicts p∤kp \nmid k. So the claim holds. (The case k=0k = 0 is covered: p∣0p \mid 0 and gcd⁡(0,pe)=pe>1\gcd(0, p^e) = p^e > 1.)

The multiples of pp in {0,…,pe−1}\{0, \ldots, p^e - 1\} are ptpt with 0≤t<pe−10 \le t < p^{e-1}. There are pe−1p^{e-1} of them. So

φ(pe)=pe−pe−1=pe−1(p−1).\varphi(p^e) = p^e - p^{e-1} = p^{e-1}(p - 1).

For e=1e = 1 this is φ(p)=p−1\varphi(p) = p - 1: only 00 is excluded. □\square

Check

φ(2)=1\varphi(2) = 1, φ(3)=2\varphi(3) = 2, φ(4)=2\varphi(4) = 2, φ(8)=4\varphi(8) = 4, φ(9)=6\varphi(9) = 6, φ(27)=18\varphi(27) = 18, φ(125)=100\varphi(125) = 100. A count with the gcd for n=1,…,10n = 1, \ldots, 10 gives 1,1,2,2,4,2,6,4,6,41, 1, 2, 2, 4, 2, 6, 4, 6, 4, and the prime powers in this list agree with the formula.

Remarks

Exercise 1.2.4-30 shows that φ\varphi is multiplicative, so these values give φ(n)\varphi(n) for every nn. Exercise 1.2.4-28 uses φ\varphi in Euler's theorem.

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.