← back to Number Theory

Congruences

Jim Hefferon · Elementary Number Theory · Ch. 3

Two integers are congruent mod n if they have the same remainder when divided by n. This single equivalence relation turns the integers into a finite arithmetic system where addition, subtraction, and multiplication all work.

Modular arithmetic

We write a ≡ b (mod n) when n divides (a - b). The integers split into n congruence classes: [0], [1], ..., [n-1]. Arithmetic on these classes is well-defined: you can add, subtract, and multiply representatives and the class of the result does not depend on which representatives you chose.

Clock arithmetic: mod 12 0 1 2 3 4 5 6 7 8 9 10 11 7 + 8 = 15 ≡ 3 (mod 12)
Scheme

Solving linear congruences

The equation ax ≡ b (mod n) has a solution if and only if gcd(a, n) divides b. When it does, the extended Euclidean algorithm finds x. If gcd(a, n) = 1, then a has a multiplicative inverse mod n.

Scheme
Neighbors
  • → Abstract Algebra Ch.1 — the integers mod n form a group under addition (and a ring under addition and multiplication)