Skip to main content

MATH 308 — Lec 15 — Congruence mod n; Z_n

Math 308 · November 6, 2026

Lecture 15 — Congruence Modulo nnn and the Integers mod nnn
MATH 308  Bridge to Advanced Mathematics  Chartrand §9.5–9.6

Goals for today. By the end of this lecture you should be able to:

  • name the nnn residue classes [0],[1],…,[n−1][0],[1],\dots,[n-1][0],[1],…,[n−1] and describe the set Zn\mathbb{Z}_nZn​ of integers modulo nnn;

  • explain why the rules [a]+[b]=[a+b][a]+[b]=[a+b][a]+[b]=[a+b] and [a]⋅[b]=[ab][a]\cdot[b]=[ab][a]⋅[b]=[ab] are well-defined — independent of representatives — and prove it;

  • build and read the addition and multiplication tables of Zn\mathbb{Z}_nZn​ for small nnn;

  • recognize Zn\mathbb{Z}_nZn​ as your first ring, and spot it on a clock, a calendar, a parity bit, and a check digit.

Residue classes and the set Zn\mathbb{Z}_nZn​ (§9.5)

Fix an integer n≥2n \ge 2n≥2. In Lecture 14 we proved that congruence modulo nnn,

a≡b(modn)⇔n∣(a−b),a \equiv b \pmod{n} \quad\Leftrightarrow\quad n \mid (a-b),a≡b(modn)⇔n∣(a−b),

is an equivalence relation on Z\mathbb{Z}Z (recall n∣mn \mid mn∣m from Lecture 7 means m=nkm = nkm=nk for some k∈Zk \in \mathbb{Z}k∈Z). Its equivalence classes are called residue classes, and today they become objects we can compute with.

Definition 1. For a∈Za \in \mathbb{Z}a∈Z, the residue class (or congruence class) of aaa modulo nnn is

[a]  =  { x∈Z  :  x≡a(modn) }  =  { a+nk  :  k∈Z }.[a] \;=\; \left\{\, x \in \mathbb{Z} \;:\; x \equiv a \pmod n \,\right\} \;=\; \left\{\, a + nk \;:\; k \in \mathbb{Z} \,\right\}.[a]={x∈Z:x≡a(modn)}={a+nk:k∈Z}.

Any b∈[a]b \in [a]b∈[a] is a representative of the class; by Lecture 14, [a]=[b]⇔a≡b(modn)[a]=[b] \Leftrightarrow a \equiv b \pmod n[a]=[b]⇔a≡b(modn).

By the Division Algorithm, every integer leaves exactly one remainder r∈{0,1,…,n−1}r \in \{0,1,\dots,n-1\}r∈{0,1,…,n−1} on division by nnn, and [a]=[r][a]=[r][a]=[r] for that rrr. So there are exactly nnn distinct classes, one per remainder.

Definition 2. The integers modulo nnn is the set of all residue classes,

Zn  =  { [0], [1], [2], …, [n−1] },∣Zn∣=n.\mathbb{Z}_n \;=\; \bigl\{\,[0],\,[1],\,[2],\,\dots,\,[n-1]\,\bigr\}, \qquad \left\lvert \mathbb{Z}_n \right\rvert = n.Zn​={[0],[1],[2],…,[n−1]},∣Zn​∣=n.

(This is the set Z/ ⁣ ⁣≡\mathbb{Z}/\!\!\equivZ/≡ of Lecture 14, also written Z/nZ\mathbb{Z}/n\mathbb{Z}Z/nZ.)

Example 1. For n=4n = 4n=4 there are four classes, each an arithmetic progression of step 444:

[0]={…,−4,0,4,8,… },  [1]={…,−3,1,5,9,… },  [2]={…,−2,2,6,10,… },  [3]={…,−1,3,7,11,… }.[0]=\{\dots,-4,0,4,8,\dots\},\ \ [1]=\{\dots,-3,1,5,9,\dots\},\ \ [2]=\{\dots,-2,2,6,10,\dots\},\ \ [3]=\{\dots,-1,3,7,11,\dots\}.[0]={…,−4,0,4,8,…},  [1]={…,−3,1,5,9,…},  [2]={…,−2,2,6,10,…},  [3]={…,−1,3,7,11,…}.

So Z4={[0],[1],[2],[3]}\mathbb{Z}_4 = \{[0],[1],[2],[3]\}Z4​={[0],[1],[2],[3]}. Note [4]=[0][4]=[0][4]=[0], [5]=[1][5]=[1][5]=[1], and [−1]=[3][-1]=[3][−1]=[3]: many labels, four classes. As in Lecture 2, the four classes partition Z\mathbb{Z}Z — they cover it and are pairwise disjoint.

The passage a↦[a]a \mapsto [a]a↦[a] folds the whole number line onto nnn points: it is a function Z→Zn\mathbb{Z}\to \mathbb{Z}_nZ→Zn​, the reduction mod nnn map (we make “function” precise in Lecture 16). Figure [fig:fold] shows the fold for n=4n=4n=4.

Reduction mod 4 folds Z onto four classes. Each integer is routed to its residue class; different representatives (e.g. 1, 5, -3) land in the same box (1). This is exactly why arithmetic on the boxes will be well-defined.

Reduction mod 444 folds Z\mathbb{Z}Z onto four classes. Each integer is routed to its residue class; different representatives (e.g. 111, 555, −3-3−3) land in the same box [1][1][1]. This is exactly why arithmetic on the boxes will be well-defined.

Adding and multiplying classes: well-definedness (§9.6)

We would like to add and multiply classes, not just integers. The natural rule is to add representatives:

[a]+[b]  =?  [a+b],[a]⋅[b]  =?  [ab].[a] + [b] \;\overset{?}{=}\; [a+b], \qquad [a]\cdot[b] \;\overset{?}{=}\; [ab].[a]+[b]=?[a+b],[a]⋅[b]=?[ab].

There is a genuine worry hiding in the question marks. A class has many names — [1]=[5][1]=[5][1]=[5] in Z4\mathbb{Z}_4Z4​ — so the recipe “pick a representative, add, take the class” might give different answers for different choices. If it did, the operation would be nonsense. We must check the answer depends only on the classes, not on the representatives chosen. This is the notion of a well-defined operation, and it is exactly what Lecture 7 set us up to prove.

Theorem 1 (Addition and multiplication on Zn\mathbb{Z}_nZn​ are well-defined). *Let n≥2n \ge 2n≥2. Suppose [a]=[a′][a]=[a'][a]=[a′] and [b]=[b′][b]=[b'][b]=[b′] in Zn\mathbb{Z}_nZn​. Then

[a+b]=[a′+b′]and[ab]=[a′b′].[a+b] = [a'+b'] \qquad\text{and}\qquad [ab] = [a'b'].[a+b]=[a′+b′]and[ab]=[a′b′].

Consequently the rules [a]+[b]:=[a+b][a]+[b]:=[a+b][a]+[b]:=[a+b] and [a]⋅[b]:=[ab][a]\cdot[b]:=[ab][a]⋅[b]:=[ab] define operations on Zn\mathbb{Z}_nZn​ that do not depend on the chosen representatives.*

Proof. By Lecture 14, [a]=[a′][a]=[a'][a]=[a′] means a≡a′(modn)a \equiv a' \pmod na≡a′(modn), and [b]=[b′][b]=[b'][b]=[b′] means b≡b′(modn)b \equiv b' \pmod nb≡b′(modn). By the theorem of Lecture 7 (congruence is preserved by +++ and ×\times×),

a+b≡a′+b′(modn)andab≡a′b′(modn).a + b \equiv a' + b' \pmod n \qquad\text{and}\qquad ab \equiv a'b' \pmod n.a+b≡a′+b′(modn)andab≡a′b′(modn).

Translating back to classes (again x≡y⇔[x]=[y]x \equiv y \Leftrightarrow [x]=[y]x≡y⇔[x]=[y]) gives [a+b]=[a′+b′][a+b]=[a'+b'][a+b]=[a′+b′] and [ab]=[a′b′][ab]=[a'b'][ab]=[a′b′], as claimed. ◻

Remark 1. This is the payoff of the humble computation in Lecture 7. “Congruence respects +++ and ×\times×” looked like a convenience for finding remainders; here it is precisely the fact that lets a whole new number system exist. Well-definedness is the recurring question behind every quotient construction we will meet.

Example 2 (Reducing before you compute). In Z4\mathbb{Z}_4Z4​, compute [2]+[3][2]+[3][2]+[3] and [3]⋅[3][3]\cdot[3][3]⋅[3]. Add/multiply representatives, then reduce:

[2]+[3]=[5]=[1],[3]⋅[3]=[9]=[1].[2]+[3] = [5] = [1], \qquad [3]\cdot[3] = [9] = [1].[2]+[3]=[5]=[1],[3]⋅[3]=[9]=[1].

By Theorem 1 we may also replace [3][3][3] by its friendlier name [−1][-1][−1] first: [3]⋅[3]=[−1]⋅[−1]=[1][3]\cdot[3]=[-1]\cdot[-1]=[1][3]⋅[3]=[−1]⋅[−1]=[1] — same answer, less arithmetic.

Because the operations are well-defined, we can tabulate them once and for all. Figure [fig:cayley] is the addition table of Z5\mathbb{Z}_5Z5​; entry in row [i][i][i], column [j][j][j] is [i+j][i+j][i+j], i.e. (i+j) mod 5(i+j)\bmod 5(i+j)mod5.

The addition table (a Cayley table) of Z5: cell (i,j) holds (i+j) 5. The diagonal color-bands are the residue classes wrapping around — add 1 and every entry steps to the next shade, looping from (4) back to (0).

The addition table (a Cayley table) of Z5\mathbb{Z}_5Z5​: cell (i,j)(i,j)(i,j) holds (i+j) mod 5(i+j)\bmod 5(i+j)mod5. The diagonal color-bands are the residue classes wrapping around — add 111 and every entry steps to the next shade, looping from [4][4][4] back to [0][0][0].

Zn\mathbb{Z}_nZn​ as a number system

The operations satisfy the same structural laws as ordinary integer arithmetic, inherited class-by-class from Z\mathbb{Z}Z.

Proposition 2 (Identities and additive inverses). *In Zn\mathbb{Z}_nZn​, for every class [a][a][a]:

[a]+[0]=[a],[a]⋅[1]=[a],[a]+[ n−a ]=[0].[a]+[0] = [a], \qquad [a]\cdot[1] = [a], \qquad [a] + [\,n-a\,] = [0].[a]+[0]=[a],[a]⋅[1]=[a],[a]+[n−a]=[0].

Moreover addition and multiplication are commutative and associative, and multiplication distributes over addition.*

Proof. The first two are immediate: [a]+[0]=[a+0]=[a][a]+[0]=[a+0]=[a][a]+[0]=[a+0]=[a] and [a]⋅[1]=[a⋅1]=[a][a]\cdot[1]=[a\cdot 1]=[a][a]⋅[1]=[a⋅1]=[a] by the definitions of the operations. For the additive inverse, [a]+[n−a]=[a+(n−a)]=[n]=[0][a]+[n-a]=[a+(n-a)]=[n]=[0][a]+[n−a]=[a+(n−a)]=[n]=[0], since n≡0(modn)n \equiv 0 \pmod nn≡0(modn). The remaining laws transfer directly from Z\mathbb{Z}Z: for commutativity of addition, [a]+[b]=[a+b]=[b+a]=[b]+[a][a]+[b]=[a+b]=[b+a]=[b]+[a][a]+[b]=[a+b]=[b+a]=[b]+[a], using a+b=b+aa+b=b+aa+b=b+a in Z\mathbb{Z}Z; associativity and distributivity are identical, each following from the corresponding law for integers applied to representatives. ◻

A set with a well-behaved addition and multiplication obeying exactly these laws — two identities, additive inverses, commutativity, associativity, distributivity — is called a commutative ring. Proposition 2 says Zn\mathbb{Z}_nZn​ is one; it is the first ring in this course other than Z\mathbb{Z}Z itself.

Example 3 (Multiplication in Z4\mathbb{Z}_4Z4​ vs. Z5\mathbb{Z}_5Z5​: a surprise). The multiplication tables (entry === product mod n\bmod nmodn) reveal that Zn\mathbb{Z}_nZn​ can behave unlike Z\mathbb{Z}Z:

⋅[0][1][2][3][0]0000[1]0123[2]0202[3]0321⋅[0][1][2][3][4][0]00000[1]01234[2]02413[3]03142[4]04321\begin{array}{c|cccc} \cdot & [0]&[1]&[2]&[3]\\\hline {[0]} & 0&0&0&0\\ {[1]} & 0&1&2&3\\ {[2]} & 0&2&0&2\\ {[3]} & 0&3&2&1 \end{array} \qquad\qquad \begin{array}{c|ccccc} \cdot & [0]&[1]&[2]&[3]&[4]\\\hline {[0]} & 0&0&0&0&0\\ {[1]} & 0&1&2&3&4\\ {[2]} & 0&2&4&1&3\\ {[3]} & 0&3&1&4&2\\ {[4]} & 0&4&3&2&1 \end{array}⋅[0][1][2][3]​[0]0000​[1]0123​[2]0202​[3]0321​​⋅[0][1][2][3][4]​[0]00000​[1]01234​[2]02413​[3]03142​[4]04321​​

In Z4\mathbb{Z}_4Z4​, [2]⋅[2]=[0][2]\cdot[2]=[0][2]⋅[2]=[0]: two nonzero classes multiply to zero. Such an [a]≠[0][a]\ne[0][a]=[0] is called a zero divisor — impossible in Z\mathbb{Z}Z, where ab=0ab=0ab=0 forces a=0a=0a=0 or b=0b=0b=0. In Z5\mathbb{Z}_5Z5​, by contrast, every nonzero row is a permutation of [1],…,[4][1],\dots,[4][1],…,[4]: each nonzero class has a multiplicative inverse (e.g. [2]⋅[3]=[6]=[1][2]\cdot[3]=[6]=[1][2]⋅[3]=[6]=[1], so [2]−1=[3][2]^{-1}=[3][2]−1=[3]). That happens exactly when nnn is prime, and makes Zp\mathbb{Z}_pZp​ a field — a number system where you can also divide. We will not prove that here, but the tables already let you see it.

Finally, the “wheel” picture from Lecture 7 is now literally the diagram of (Zn,+)(\mathbb{Z}_n, +)(Zn​,+): adding [1][1][1] rotates the wheel one notch, and after nnn steps you return to [0][0][0].

(Z6,+) as a 6-point wheel: adding (1) steps one node clockwise. Reading (5)+(3): start at (5), step 3 notches to (2), matching (5+3)=(8)=(2).

(Z6,+)(\mathbb{Z}_6,+)(Z6​,+) as a 666-point wheel: adding [1][1][1] steps one node clockwise. Reading [5]+[3][5]+[3][5]+[3]: start at [5][5][5], step 333 notches →[2]\to [2]→[2], matching [5+3]=[8]=[2][5+3]=[8]=[2][5+3]=[8]=[2].

Homework problems

  1. List the elements (five each) of the three classes of Z3\mathbb{Z}_3Z3​, and confirm they partition Z\mathbb{Z}Z.

  2. In Z7\mathbb{Z}_7Z7​ compute [4]+[5][4]+[5][4]+[5], [3]⋅[6][3]\cdot[6][3]⋅[6], and [6]⋅[6][6]\cdot[6][6]⋅[6], reducing each to a representative in {0,…,6}\{0,\dots,6\}{0,…,6}.

  3. Build the full addition table of Z4\mathbb{Z}_4Z4​. Circle the additive inverse of each class.

  4. Well-definedness in action. Verify [2]⋅[3]=[7]⋅[8][2]\cdot[3]=[7]\cdot[8][2]⋅[3]=[7]⋅[8] in Z5\mathbb{Z}_5Z5​ by computing both sides. Which theorem guarantees they must agree?

  5. Find every zero divisor in Z6\mathbb{Z}_6Z6​ (classes [a]≠[0][a]\ne[0][a]=[0] with [a][b]=[0][a][b]=[0][a][b]=[0] for some [b]≠[0][b]\ne[0][b]=[0]). Which classes have a multiplicative inverse instead?

  6. Using Z9\mathbb{Z}_9Z9​ and the fact that 10≡1(mod9)10 \equiv 1 \pmod 910≡1(mod9), prove the “casting out nines” rule: an integer is ≡\equiv≡ (the sum of its base-101010 digits) (mod9)\pmod 9(mod9). (Hint:  dk10k≡dk(mod9)\,d_k10^k \equiv d_k \pmod 9dk​10k≡dk​(mod9).)

Suggested textbook exercises (Chartrand §9.5–9.6): 9.36, 9.38, 9.40, 9.44, 9.48, 9.52.

← Back to Math 308