Euler's Phi Function: The Art of Counting Coprimes
One of my favorite moments in teaching number theory is when students first encounter Euler's phi function. "Wait," they say, "we're counting numbers based on whether they share factors?" Yes! And this simple idea unlocks some of the most beautiful results in mathematics . What is Euler's Phi Function? Euler's phi function (also called Euler's totient function), denoted φ(n), counts how many positive integers less than or equal to n are relatively prime to n (i.e., share no common factors except 1 with n). φ(n) = |{k : 1 ≤ k ≤ n and gcd(k, n) = 1}| Examples Example 1: φ(10) Numbers from 1 to 10: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} Which are coprime to 10? 1: gcd(1, 10) = 1 ✓ 2: gcd(2, 10) = 2 ✗ 3: gcd(3, 10) = 1 ✓ 4: gcd(4, 10) = 2 ✗ 5: gcd(5, 10) = 5 ✗ 6: gcd(6, 10) = 2 ✗ 7: gcd(7, 10) = 1 ✓ 8: gcd(8, 10) = 2 ✗ 9: gcd(9, 10) = 1 ✓ 10: gcd(10, 10) = 10 ✗ So φ(10) = 4 (the numbers 1, 3, 7, 9) Example 2: φ(7) Since 7 is prime, every number from 1 to ...