← LibraryResidue Classes and the Ring of Integers Modulo nEngineering · MathematicsLesson 41/385← PrevNext →
ArticlePublished 7 Aug 20264 min readBy Kevin Jogin

Engineering  /  Mathematics  — Integer Foundations

Residue Classes and the Ring of Integers Modulo n

The ring Z_n of residue classes, its units and zero divisors, and the condition under which it is a field.

Page KV-MATH-0312Reading time 4 minReviewed 2026-08-07Author Kevin Jogin

Executive summary

Collecting the congruence classes modulo n into a single object turns modular arithmetic from a manipulation technique into an algebraic structure. Z_n is a finite commutative ring, and its properties are entirely determined by the factorisation of n.

The distinction between units and zero divisors within Z_n governs which operations are available and is the reason prime moduli behave so differently from composite ones.

Learning objectives

  1. Construct Z_n as a ring of residue classes and verify well-definedness.
  2. Characterise the units and zero divisors of Z_n.
  3. State the condition for Z_n to be a field.

01Constructing the ring

Definition

The ring Z_n

Z_n is the set of congruence classes modulo n, with operations

[a] + [b] = [a + b]   and   [a] · [b] = [ab].

These operations are well defined precisely because congruence is compatible with addition and multiplication: choosing different representatives from the same classes produces results in the same class. Without that compatibility the definition would be incoherent.

The resulting structure is a commutative ring with identity [1], containing exactly n elements. It inherits associativity, commutativity and distributivity from the integers, since each is checked on representatives.

02Units and zero divisors

Theorem

Characterisation of units

An element [a] ∈ Z_n is a unit — that is, has a multiplicative inverse — if and only if gcd(a, n) = 1.

One direction is Bezout: if gcd(a,n) = 1 then as + nt = 1 for some s, t, so as ≡ 1 (mod n) and [s] is the inverse. Conversely if [a][b] = [1] then ab − 1 = kn, so any common divisor of a and n divides 1.

Theorem

Characterisation of zero divisors

A non-zero [a] ∈ Z_n is a zero divisor — there is a non-zero [b] with [a][b] = [0] — if and only if gcd(a, n) > 1.

So every non-zero element of Z_n is either a unit or a zero divisor, with no third possibility. This dichotomy is special to finite rings and fails in the integers, where 2 is neither.

Unit and zero-divisor structure for small moduli
nUnitsZero divisorsStructure
7 (prime)1,2,3,4,5,6noneField
8 = 2³1,3,5,72,4,6Local ring
12 = 2²·31,5,7,112,3,4,6,8,9,10Product of local rings

03When Z_n is a field

Theorem

Field criterion

Z_n is a field if and only if n is prime.

If n is prime, every non-zero residue is coprime to n, hence a unit, which is exactly the field condition. If n is composite, say n = ab with both factors strictly between 1 and n, then [a][b] = [0] with neither factor zero, so zero divisors exist and the ring is not even an integral domain.

The number of units in Z_n is Euler's phi function φ(n), and those units form a group under multiplication, written Z_n*. That group is the central object of the primality and discrete logarithm streams.

04Frequently asked questions

Why does every non-zero element have to be a unit or a zero divisor?

Because Z_n is finite. Multiplication by a fixed non-zero element is a map from a finite set to itself; if it is injective it is surjective, giving a unit, and if it is not injective two elements collide, whose difference is annihilated, giving a zero divisor.

Is Z_n for n = p^k a field?

No, only n prime gives a field. In Z_{p^k} the element p is a zero divisor since p · p^{k−1} = 0. The field with p^k elements exists but is constructed differently, as a quotient of a polynomial ring.

Why does x² ≡ 1 (mod 8) have four solutions?

Because Z_8 is not a field, so the usual argument bounding root count by degree fails. That argument relies on factoring x² − 1 = (x−1)(x+1) and concluding one factor is zero, which requires the absence of zero divisors.

Sources and method

Structural reference: Victor Shoup, A Computational Introduction to Number Theory and Algebra, Version 1, Cambridge University Press, 2005 — book pages 20-24.

This page carries the durable method layer only: definitions, constructions, algorithms, complexity results and selection criteria, authored originally for KEVOS. No text is transcribed or paraphrased from the source, and no numeric tables or benchmark data are reproduced — these are routed to live authoritative sources instead.

Author: Kevin Jogin. Last reviewed 2026-08-07.

Continue learning

Solving Linear CongruencesArticle · MathematicsNEXT LESSON →The Chinese Remainder TheoremArticle · MathematicsCongruences and Modular ArithmeticArticle · MathematicsEuler's Phi FunctionArticle · Mathematics