This note continues the Fermat’s Little Theorem note, whose reduced residue systems and multiplicative orders it uses throughout. As before, all variables are integers unless otherwise specified, and the modulus m is always a positive integer.
Euler’s Phi Function
Definition 15 (Euler's Phi Function).
For every m∈N,,φ(m) is defined as the number of elements in any reduced residue system modulo m.. Symbolically,
φ(m)=∣{a∈Z:0≤a≤m−1 and gcd(a,m)=1}∣.
As noted in Complete and Reduced Residue Systems of the Fermat’s Little Theorem note, all reduced residue systems modulo m have the same size, so φ(m) is well defined. For example, {1,3,7,9} is a reduced residue system modulo 10,, so φ(10)=4.. For any prime p,,{1,2,…,p−1} is a reduced residue system modulo p,, so φ(p)=p−1.. Also φ(1)=1,, since gcd(0,1)=1..
Proposition 16.
For any prime p and positive integer α,,
φ(pα)=pα−pα−1.
Proof.
An integer is coprime to pα if and only if it is not divisible by p.. Among the pα integers 0,1,…,pα−1,, the multiples of p are 0,p,2p,…,(pα−1−1)p,, and there are pα−1 of them. The remaining pα−pα−1 integers are coprime to pα..
For example, φ(8)=8−4=4 (the reduced residues are 1,3,5,7)) and φ(9)=9−3=6..
Proposition 17.
Euler’s phi function is multiplicative: if gcd(m,n)=1,, then φ(mn)=φ(m)φ(n)..
Proof sketch.
By the Chinese Remainder Theorem (Theorem 16 of the Congruence note), each x∈{0,1,…,mn−1} corresponds to exactly one pair (xmodm,xmodn),, and every pair occurs. Now gcd(x,mn)=1 if and only if gcd(x,m)=1 and gcd(x,n)=1 (by Proposition 3 of the Fermat’s Little Theorem note for one direction; any common prime factor of x and m or n also divides mn for the other). Moreover, gcd(x,m)=gcd(xmodm,m),, since x and xmodm differ by a multiple of m.. Hence x is coprime to mn exactly when xmodm is one of the φ(m) reduced residues modulo m and xmodn is one of the φ(n) reduced residues modulo n.. There are φ(m)φ(n) such pairs.
For example, φ(10)=φ(2)φ(5)=1×4=4,, matching the reduced residue system {1,3,7,9}.. Combining the two propositions above with the prime factorization gives a formula for φ(n)..
Proposition 18.
Suppose n∈N has the prime factorization
n=p1α1p2α2⋯pkαk,
where p1,p2,…,pk are distinct primes and α1,α2,…,αk are positive integers. Then
The prime powers p1α1,p2α2,…,pkαk are pairwise coprime, so repeated application of Proposition 17 gives φ(n)=φ(p1α1)φ(p2α2)⋯φ(pkαk).. Now apply Proposition 16 to each factor. The second form follows from pα−pα−1=pα(1−p1)..
Example 19.
Since 100=22×52,,
φ(100)=(22−2)(52−5)=2×20=40.
Equivalently, φ(100)=100(1−21)(1−51)=40.. So exactly 40 of the integers 1,2,…,100 are coprime to 100..
Euler’s Theorem generalizes Fermat’s Little Theorem from a prime modulus to an arbitrary modulus.
Theorem 21 (Euler's Theorem).
For any a∈Z and m∈N with gcd(a,m)=1,, we have
aφ(m)≡1(modm).
In other words, by Proposition 8 of the Fermat’s Little Theorem note, ordm(a)∣φ(m)..
Proof.
The argument is the same as for Fermat’s Little Theorem, with an arbitrary reduced residue system in place of {1,2,…,p−1}.. Let T={r1,r2,…,rk} be a reduced residue system modulo m,, where k=φ(m).. By Lemma 5 of the Fermat’s Little Theorem note,
When m=p is prime, φ(p)=p−1,, and Euler’s Theorem becomes Fermat’s Little Theorem. When m=10,,φ(10)=4,, and Euler’s Theorem says a4≡1(mod10) for every a coprime to 10;; this explains why the units digits of powers of 1,,3,,7,,9 repeat with period dividing 4 (compare Example 7 of the Fermat’s Little Theorem note).
Example 22.
Find the last two digits of 32026..
Solution
We work modulo 100.. Since gcd(3,100)=1 and φ(100)=40 by Example 19, Euler’s Theorem gives 340≡1(mod100).. Since 2026=40×50+26,,
32026=(340)50×326≡326(mod100).
Now 35=243≡43,,310≡432=1849≡49,, and 320≡492=2401≡1(mod100).. Therefore 326=320×36≡729≡29(mod100),, and the last two digits are 29..
Remark. The computation shows more: since 320≡1(mod100),, while 320/2=310≡49 and 320/5=34=81 are not ≡1(mod100),, the remark after Proposition 8 of the Fermat’s Little Theorem note gives ord100(3)=20,, a proper divisor of φ(100)=40.. Euler’s Theorem gives an exponent that works, but not necessarily the smallest one. On the AMC, it is often fastest to compute a few powers directly and look for the cycle.
Exercise 23.
Find the last two digits of 72026..
Hint: Compute 74..
Exercise 24.
Find the remainder when 5100 is divided by 36..
Answers
23. By Euler’s Theorem, 740≡1(mod100),, but in fact 74=2401≡1(mod100).. Since also 72=49≡1(mod100),, we get ord100(7)=4.. Since 2026=4×506+2,, we get 72026≡72=49(mod100).. The last two digits are 49..
24.φ(36)=φ(4)φ(9)=2×6=12 and gcd(5,36)=1,, so 512≡1(mod36).. Since 100=12×8+4,, we get 5100≡54=625=17×36+13≡13(mod36).. The remainder is 13..
Application: Repeating Decimals
The multiplicative order also explains the length of the repeating block in decimals such as
71=0.142857=0.142857142857142857…
Proposition 25.
Let n>1 with gcd(n,10)=1.. Then the decimal expansion of n1 is purely periodic, and the length of its shortest repeating block is ordn(10).. In particular, this length divides φ(n)..
Proof.
Suppose 10k≡1(modn) for some positive integer k,, and write 10k−1=nA.. Since n>1,, we have 0<A<10k,, and
n1=10k−1A=10kA⋅1−10−k1=10kA+102kA+103kA+⋯,
so the decimal expansion of n1 repeats the k digits of A (padded with leading zeros if necessary). By Euler’s Theorem such a k exists, so the expansion is purely periodic, and taking k=ordn(10) gives a repeating block of length ordn(10)..
Conversely, suppose the expansion repeats with a block of length k.. Moving the decimal point k places to the right, n10k has the same digits after the decimal point as n1,, so n10k−1 is an integer. Thus 10k≡1(modn),, and hence k≥ordn(10).. The last statement follows from Euler’s Theorem.
Example 26.
Since 10≡3(mod7) and ord7(3)=6 (Exercise 13 of the Fermat’s Little Theorem note), the repeating block of 71 has length 6.. Indeed, 106−1=999999=7×142857..
For n=13,, we have 102=100≡9 and 103≡90≡−1(mod13),, so 106≡1(mod13),, while 106/2≡1 and 106/3≡1.. Hence ord13(10)=6,, and indeed 131=0.076923,, since 999999=13×76923..
Exercise 27.
Find the length of the repeating block of 371 and of 411..
Answer
Since 103−1=999=27×37 and 10≡1(mod37),, we get ord37(10)=3,, and 371=0.027.. Since 105−1=99999=41×2439,,5 is prime, and 10≡1(mod41),, we get ord41(10)=5,, and 411=0.02439..
Last Two Digits and the Chinese Remainder Theorem
Euler’s Theorem requires gcd(a,m)=1,, so it does not directly give the last two digits of a power of 2 or 5.. In such cases, split 100=4×25 with gcd(4,25)=1,, work modulo 4 and modulo 25 separately, and recombine with the Chinese Remainder Theorem (Theorem 16 of the Congruence note).
Example 28.
Find the last two digits of 22026..
Solution
Modulo 4:: since 22=4,, we have 22026≡0(mod4).. Modulo 25:: since gcd(2,25)=1 and φ(25)=25−5=20,, Euler’s Theorem gives 220≡1(mod25).. Since 2026=20×101+6,, we get 22026≡26=64≡14(mod25).. The numbers below 100 that are ≡14(mod25) are 14,39,64,89,, and only 64 is divisible by 4.. Therefore 22026≡64(mod100),, and the last two digits are 64..
Splitting 100=4×25 helps even when gcd(a,10)=1.. In that case a is odd, so a2≡1(mod4) (since φ(4)=2),), and a20≡1(mod25) by Euler’s Theorem. Hence 4 and 25 both divide a20−1,, and since they are coprime,
a20≡1(mod100)for every a with gcd(a,10)=1.
So the exponent 20 works in place of φ(100)=40.. This explains why ord100(3)=20 and ord100(7)=4 (Example 22 and Exercise 23) both divide 20..
Power Towers
A power tower abc means a(bc).. To find it modulo m,, work from the top down: if ak≡1(modm),, then aN≡aNmodk(modm),, so it suffices to find the exponent N=bc modulo the smaller number k..
Example 29.
Find the last two digits of 332026..
Solution
Let N=32026.. Since 320≡1(mod100),, we need Nmod20.. Now 34=81≡1(mod20) and 2026=4×506+2,, so N≡32=9(mod20).. Therefore
332026=3N≡39=19683≡83(mod100),
and the last two digits are 83.. The moduli shrink at each level of the tower: 100,, then 20,, then 4..
Exercise 30.
Find the last two digits of 777..
Answer
Since 74≡1(mod100),, we need 77mod4.. As 7≡−1(mod4),, we get 77≡−1≡3(mod4).. Therefore 777≡73=343≡43(mod100),, and the last two digits are 43..
Practice Problems
For how many integers k with 1≤k≤360 is the fraction 360k in lowest terms?
(C) 96. The fraction 360k is in lowest terms exactly when gcd(k,360)=1.. Since 360≡0(mod360),, the integers 1,2,…,360 form a complete residue system modulo 360,, so the count is φ(360).. As 360=23×32×5,,
φ(360)=360(1−21)(1−31)(1−51)=96.
Problem 2
(D) 4. We find the last two digits. As in Exercise 23, 74=2401≡1(mod100).. Since 2011=4×502+3,, we get 72011≡73=343≡43(mod100).. The tens digit is 4..
Problem 3
(D) 6. We work modulo 10=2×5,, using the Chinese Remainder Theorem as in Example 28. First, 20082≡82=64≡4(mod10),, and 22008≡6(mod10),, since 22008 is even and 22008=(24)502≡1(mod5).. So k≡4+6≡0(mod10),, and k2≡0(mod10).. Next, both 20082 and 22008 are divisible by 4,, so 4∣k.. Hence 2k is even and 2k=(24)k/4≡1(mod5),, which gives 2k≡6(mod10).. Therefore k2+2k≡0+6=6(mod10)..
Problem 4
35. Since gcd(6,49)=gcd(8,49)=1 and φ(49)=49−7=42,, Euler’s Theorem gives 642≡842≡1(mod49).. Since 83=2×42−1,, we get 683×6=684≡1,, i.e., 683≡6−1(mod49),, and similarly 883≡8−1(mod49).. Now 6×8=48≡−1(mod49),, so 6−1≡−8 and 8−1≡−6(mod49).. Therefore