Putting Modular Arithmetic to Work
Modular arithmetic is not just theory — it powers check digits, hashing, calendars, and cryptography. This lesson develops the tools to solve modular equations and see where they apply.
A linear congruence has the form — solve for the unknown residue . The key is the multiplicative inverse: is a residue with . When it exists, multiply both sides by it to get . The crucial fact from Lesson 4: has an inverse mod if and only if (they are coprime). So has a unique solution exactly when and are coprime; otherwise it may have several solutions or none.
Two celebrated theorems make computation easy:
- Fermat's little theorem — if is prime and , then . This gives inverses () and fast primality tests.
- The Chinese remainder theorem — a system of congruences with coprime moduli has a unique solution modulo the product of the moduli, letting you reassemble a number from its remainders.
Applications are everywhere. Check digits (ISBN, credit cards) append a digit making a weighted sum , so single-digit errors are caught. Hash functions reduce keys mod a table size. And public-key cryptography (RSA) rests entirely on modular exponentiation being easy while its inverse (factoring, or the discrete logarithm) is hard — the coprimality and inverse ideas of this unit, scaled to enormous numbers.
Common pitfall: trying to solve by "dividing by " when and are not coprime. The inverse exists only when ; without it you cannot simply divide. When the congruence has either no solution or several (never a single unique one) — checking coprimality first tells you which case you are in.