Congruences and Linear Congruences
Congruence means — two integers leave the same remainder when divided by . A linear congruence is solvable iff , in which case it has exactly solutions modulo . Used throughout number theory, cryptography, and computer arithmetic. Concept formalized by Gauss in Disquisitiones Arithmeticae (1801).
Divisibility by is an equivalence relation that respects addition and multiplication. This lets us "compute modulo " inside a finite ring. Solving then reduces to a divisibility test () plus the Extended Euclidean Algorithm, which simultaneously certifies solvability and produces the solution.
Formal Statement
Let be a positive integer. Integers and are congruent modulo , written , if divides their difference:
Derivation hint: " divides " means for some integer ; apply directly to . Here , is the modulus, and is the integer quotient of the difference. Equivalently, and have the same remainder under Euclidean division by .
The residue class of modulo is the set
Derivation hint: collect all integers congruent to ; by [1] they differ from by a multiple of . There are exactly distinct residue classes , forming the quotient ring under the well-defined operations and .
For fixed , congruence mod is reflexive, symmetric, and transitive, and is preserved by addition, subtraction, and multiplication: if and , then
Derivation hint: write , ; then and , both multiples of .
A linear congruence in the unknown is
Derivation hint: replace the equality in the linear equation by congruence mod . A solution is any integer satisfying [4]; solutions come in entire residue classes, so we count solutions modulo (incongruent solutions).
Let . The congruence has a solution iff . When solvable, it has exactly incongruent solutions modulo . If is any one solution, all solutions are
Derivation hint: divide through by to get with and , which has a unique solution mod ; lift back to to get classes spaced apart.
Why It Holds / Derivation
Step 1 — Reformulate as a Bézout problem. By [1], means , i.e. there exists with , equivalently the linear Diophantine equation
Step 2 — Apply Bézout's identity. This Diophantine equation in is solvable iff . Set . If there is no solution; this proves the solvability criterion.
Step 3 — Reduce to a coprime modulus. Assume and write , , with . Dividing by yields
Step 4 — Unique solution mod . Since , is invertible in (see [7] below). Multiplying by gives a unique .
Step 5 — Lift to and count. A residue class mod splits into residue classes mod , namely . These are exactly the incongruent solutions in [5].
∎If , then (cancellation is valid). More generally,
Derivation hint: ; remove the common factor from and , leaving since the reduced cofactor of is coprime to it. Consequently has a multiplicative inverse modulo iff , satisfying
Derivation hint: Bézout gives integers with ; reducing mod gives , so .
Building Intuition
intuition Think of a clock with hours. Adding always wraps around, so behaves like a finite circular ruler. Solving asks: "starting at and stepping by each time, do I ever land exactly on ?" The reachable points are precisely the multiples of on the dial. If is one of them, you can land there in symmetric ways; if it is not, you never can. This is why the gcd — not the magnitude of — controls everything.
Gauss introduced the notation and the very word "congruence" in Disquisitiones Arithmeticae (1801), written when he was in his early twenties. By treating like , he revealed that the integers carry a rich algebraic structure under divisibility, unifying scattered results of Fermat, Euler, and Lagrange. His systematic theory of congruences — including quadratic reciprocity, proved in the same work — founded modern number theory and made the modulus a first-class object of computation.
Worked Examples
Solve .
Given: . 1. Compute . Since , a solution exists, and it is unique mod . 2. Find via Extended Euclid: , so . 3. Multiply: . 4. Check: . ✓
Solve .
Given: . 1. . Since , the congruence is solvable with exactly incongruent solutions mod . 2. Divide through by : . 3. Solve the reduced congruence: (since ), so . Take . 4. Lift using [5] with : . 5. Check : . ✓
Common Misconceptions
You cannot always cancel a common factor. From ... harmless, but from you may not conclude — it happens to be false (). Cancellation of is legal only when ; otherwise the modulus must shrink to as in [6]. A second frequent error is treating as if it always has a unique solution like a real equation; the solution count is , which may be (no solutions) or larger than .
Consider . Here but , so no solution exists. Indeed is always even, hence and can never equal . This shows the criterion is genuinely necessary: an innocent-looking linear congruence can be outright unsolvable.
Connections
Congruences are the foundation of Modular Arithmetic and the ring structure of Quotient Rings: is the prototypical quotient. Systems of simultaneous congruences with coprime moduli are solved by the Chinese Remainder Theorem, which reassembles the ring as a product . The invertibility criterion identifies the Units in Modular Arithmetic, whose count is Euler's Totient Function , and whose order theory yields Fermat's Little Theorem and Euler's Theorem. The constructive engine throughout is the Extended Euclidean Algorithm.
Real-World Applications
Historical Development
Subtleties & Limits
While linear congruences are completely solved by the gcd criterion, their nonlinear cousins remain deep. Solving is trivial, but solving the discrete logarithm has no known efficient classical algorithm and underlies modern cryptography; Shor's quantum algorithm solves it in polynomial time, so its real-world hardness is conditional. Likewise, counting or finding solutions to general polynomial congruences mod composite is intimately tied to integer factorization. Even the distribution of solutions of as vary feeds open questions in analytic number theory about equidistribution of residues and the spacing of modular inverses (the Lehmer problem on of ).
See Also
Modular Arithmetic · Chinese Remainder Theorem · Extended Euclidean Algorithm · Euler's Totient Function · Fermat's Little Theorem · Quadratic Reciprocity · Quotient Rings · Discrete Logarithm