Congruence Modulo n
Definition
For integers a,b and a positive integer n≥1, we say a is congruent to b modulo n, written a≡b(modn), if and only if:
n∣(a−b)
Equivalently, a≡b(modn) iff a and b have the same remainder when divided by n.
Examples
- 17≡5(mod12) since 17−5=12 and 12∣12
- 23≡2(mod7) since 23−2=21 and 7∣21
- −5≡3(mod8) since −5−3=−8 and 8∣−8
Congruence is an Equivalence Relation
Reflexivity
a≡a(modn)
Since n∣(a−a)=0 for all n.
Symmetry
a≡b(modn)⇒b≡a(modn)
Since n∣(a−b) implies n∣(b−a).
Transitivity
a≡b(modn)∧b≡c(modn)⇒a≡c(modn)
Proof: n∣(a−b) and n∣(b−c) implies n∣[(a−b)+(b−c)]=a−c.
Congruence Classes
The congruence class of a modulo n is:
[a]n={b∈Z:a≡b(modn)}={a+kn:k∈Z}
Examples
- [0]3={…,−6,−3,0,3,6,9,…}
- [1]3={…,−5,−2,1,4,7,10,…}
- [2]3={…,−4,−1,2,5,8,11,…}
Number of Classes
There are exactly n congruence classes modulo n: [0]n,[1]n,…,[n−1]n.
The standard representatives are Zn={0,1,2,…,n−1}.
Arithmetic Operations on Congruences
Addition
If a≡b(modn) and c≡d(modn), then:
a+c≡b+d(modn)
Multiplication
If a≡b(modn) and c≡d(modn), then:
ac≡bd(modn)
Powers
If a≡b(modn), then for any k≥0:
ak≡bk(modn)
Proof (Multiplication)
Given a≡b(modn) and c≡d(modn):
ac−bd=ac−bc+bc−bd=c(a−b)+b(c−d)
Since n∣(a−b) and n∣(c−d), we have n∣[c(a−b)+b(c−d)]=ac−bd.
Thus ac≡bd(modn).
Common Pitfall: Cancellation
The Problem
ac≡bc(modn)⇒a≡b(modn)
Counterexample
2⋅3≡2⋅0(mod6) but 3≡0(mod6).
When Does Cancellation Work?
If gcd(c,n)=1 and ac≡bc(modn), then a≡b(modn).
Proof: ac≡bc(modn) means n∣c(a−b).
Since gcd(c,n)=1, Euclid’s lemma gives n∣(a−b).
Thus a≡b(modn).
Divisibility Tests
Test for 2
∣akak−1…a1a0∣ is divisible by 2 iff a0 (the last digit) is even.
Reason: 10≡0(mod2), so ak⋅10k+⋯+a1⋅10+a0≡a0(mod2).
Test for 3
A number is divisible by 3 iff the sum of its digits is divisible by 3.
Reason: 10≡1(mod3), so ak⋅10k+⋯+a1⋅10+a0≡ak+⋯+a0(mod3).
Test for 9
A number is divisible by 9 iff the sum of its digits is divisible by 9.
Reason: 10≡1(mod9).
Test for 11
A number is divisible by 11 iff the alternating sum of digits (a0−a1+a2−⋯) is divisible by 11.
Reason: 10≡−1(mod11).
Summary
- a≡b(modn) iff n∣(a−b)
- Congruence is an equivalence relation
- Congruences preserve addition and multiplication
- Cancellation requires gcd(c,n)=1
- Divisibility tests use modular arithmetic