Why does Euler's theorem require gcd(a, n) = 1? What goes wrong — concretely — if a and n share a common factor?
Think about your answer, then reveal below.
Model answer: If gcd(a, n) = d > 1, then a is not a unit in ℤ/nℤ — it has no multiplicative inverse. Powers of a mod n cannot cycle back to 1 because a unit multiplied by a non-unit never yields a unit. For example, a = 2, n = 4: powers of 2 mod 4 are 2, 0, 0, 0, … — they never reach 1. The group structure underlying Euler's theorem applies only to the units (ℤ/nℤ)×, and a ∉ (ℤ/nℤ)× when gcd(a,n) > 1.
This condition is not just a technical nicety — it is the heart of why RSA works. In RSA, messages are encoded as integers a with gcd(a, n) = 1 (guaranteed by choosing large prime factors). Encryption raises a to an exponent e, and decryption uses Euler's theorem to find the inverse exponent d such that ed ≡ 1 (mod φ(n)), recovering a. If a shared a factor with n, the cycle structure breaks and decryption fails — which is also why RSA keys use large primes, making such collisions astronomically unlikely.