Solving Congruences
Modular arithmetic powers check digits, hashing, calendars, and cryptography. A linear congruence has the form , solved for the unknown residue .
The key tool is the multiplicative inverse: is a residue satisfying . Multiplying both sides by it yields .
has an inverse mod if and only if (coprime). Thus, has a unique solution when coprime; otherwise it yields several or none.
| Modulus Case | Condition | Solution Outcome |
|---|---|---|
| Coprime | Unique solution | |
| Not Coprime | None or several |
Common pitfall: Never "divide by " when and are not coprime. The inverse only exists when .
Theorems & Applications
Two celebrated theorems make modular computation easy and powerful:
- Fermat's little theorem: If is prime and , then . This provides inverses via and enables fast primality tests.
- The Chinese remainder theorem: A system of congruences with coprime moduli has a unique solution modulo the product of moduli, reassembling a number from remainders.
Applications are everywhere:
- Check digits: ISBN and credit cards append a digit making a weighted sum to catch errors.
- Hash functions: Reduce keys modulo a table size.
- Public-key cryptography (RSA): Rests on modular exponentiation being easy while its inverse (factoring or discrete logarithm) is hard.