Courses / Mathematics I
Arithmetic and Number Theory

Congruences and Applications

Mathematics I 276 words Free to read

Solving Congruences

Modular arithmetic powers check digits, hashing, calendars, and cryptography. A linear congruence has the form ax≡b(modn)ax \equiv b \pmod{n}, solved for the unknown residue xx.

The key tool is the multiplicative inverse: a−1a^{-1} is a residue satisfying a⋅a−1≡1(modn)a \cdot a^{-1} \equiv 1 \pmod n. Multiplying both sides by it yields x≡a−1bx \equiv a^{-1} b.

aa has an inverse mod nn if and only if gcd⁡(a,n)=1\gcd(a, n) = 1 (coprime). Thus, ax≡b(modn)ax \equiv b \pmod n has a unique solution when coprime; otherwise it yields several or none.

Modulus Casegcd⁡(a,n)\gcd(a, n) ConditionSolution Outcome
Coprimegcd⁡(a,n)=1\gcd(a, n) = 1Unique solution
Not Coprimegcd⁡(a,n)>1\gcd(a, n) > 1None or several

Common pitfall: Never "divide by aa" when aa and nn are not coprime. The inverse a−1a^{-1} only exists when gcd⁡(a,n)=1\gcd(a, n) = 1.

Multiplying by $a$ mod $n$: a perfect shuffle when coprime, a pileup otherwise

Theorems & Applications

Two celebrated theorems make modular computation easy and powerful:

Applications are everywhere:

Practise this lesson

Try the questions below, free, answers included. The full set, with its interactive scenes, is in the Tryals app.

10practice questions
2interactive scenes

Arithmetic and Number Theory