Euler's Totient Function φ(n)
φ(n) counts how many integers from 1 to n are coprime to n (share no common factor other than 1).
Step-by-step: Compute φ(36)
Method 1 — Direct counting:
List integers 1 to 36 and check which are coprime to 36 (i.e., gcd(k,36)=1):
36=22×32. So we exclude multiples of 2 and multiples of 3.
Coprime to 36: 1,5,7,11,13,17,19,23,25,29,31,35. Count: 12.
Method 2 — Formula:
For n=p1a1×p2a2×⋯:
φ(n)=n(1−p11)(1−p21)⋯
For 36=22×32:
φ(36)=36(1−21)(1−31)=36×21×32=36×31=12
φ(36)=12
Euler's Theorem
If gcd(a,n)=1, then:
aφ(n)≡1(modn)
This generalizes Fermat's little theorem (which is the special case where n is prime, so φ(n)=n−1).
Step-by-step: Find 7100mod36
Step 1: gcd(7,36)=1 ✓ and φ(36)=12.
Step 2: By Euler's theorem, 712≡1(mod36).
Step 3: 100=12×8+4, so 7100=(712)8×74≡18×74≡74(mod36).
Step 4: 72=49≡13(mod36). 74=132=169≡169−4×36=169−144=25(mod36).
7100≡25(mod36)
Special values of φ
- φ(p)=p−1 for prime p
- φ(pk)=pk−pk−1=pk−1(p−1)
- φ is multiplicative: φ(mn)=φ(m)φ(n) when gcd(m,n)=1
Try it in the visualization
Enter n. The integers 1 to n are displayed — those coprime to n are highlighted. The count gives φ(n). Then enter base a and exponent e to compute aemodn using Euler's theorem.