Congruences and Modular Arithmetic

What time is it, ten hours after 9 o'clock? Nobody computes 9+10=199+10=19 and stops there. Everyone instinctively subtracts 1212 to get 77. This everyday act of "wrapping around" is arithmetic modulo 1212. It is the seed of one of the most powerful ideas in number theory: congruence. Introduced by Carl Friedrich Gauss in 1801, the congruence notation replaces cumbersome divisibility statements. It offers a clean algebraic notation that behaves almost exactly like equality. The idea matters because so many questions about integers are really questions about remainders. Is a number divisible by 9? Look at its digit sum modulo 9. Does x2+1=0x^2+1=0 have a solution mod a prime pp? That depends only on pp modulo 44. Whole swaths of number theory are conversations conducted entirely in the language of congruences. This includes divisibility tests, the structure of the integers modulo nn, and cryptographic algorithms like RSA. Congruences let us do algebra with remainders instead of with the integers themselves. They discard the irrelevant "bulk" of a number. Only what matters for a given question remains. The big picture is that congruence mod nn is an equivalence relation. It is compatible with addition, subtraction, and multiplication. This means the integers modulo nn do not just form a set of equivalence classes. They form a genuine algebraic system, later named Z/nZ\mathbb{Z}/n\mathbb{Z}. In this system you can add, subtract, and multiply representatives. You get consistent, well-defined answers. This compatibility is not automatic for arbitrary equivalence relations. It is a theorem that must be proved. Proving it rigorously is the central goal of this article. This article builds the theory from the Division Algorithm up. It covers the formal definition of congruence and the proof that it is an equivalence relation. It also covers the three arithmetic laws — addition, subtraction, multiplication — that make modular arithmetic a working calculus. Division is deliberately excluded here. It requires care about invertibility and is the subject of Linear Congruences. What follows sets the stage for Residue Classes and Complete Residue Systems. It eventually leads to Fermat's Little Theorem.

Key takeaways
  • Congruence mod nn: a≡b(modn)a \equiv b \pmod n means n∣(a−b)n \mid (a-b), a purely divisibility-based definition.
  • It is an equivalence relation: reflexive, symmetric, transitive — this partitions Z\mathbb{Z} into nn residue classes.
  • Congruences add, subtract, and multiply just like equations: if a≡ba\equiv b and c≡d(modn)c \equiv d \pmod n, so do a+ca+c, a−ca-c, acac.
  • A special case of multiplication gives exponentiation compatibility: a≡b(modn)  ⟹  ak≡bk(modn)a\equiv b \pmod n \implies a^k \equiv b^k \pmod n.
  • Division is not automatic: ac≡bc(modn)ac \equiv bc \pmod n does not imply a≡b(modn)a \equiv b \pmod n unless gcd⁡(c,n)=1\gcd(c,n)=1.
  • These laws justify classical tests like "a number is divisible by 9 iff its digit sum is," proved rigorously below.
  • Key idea: congruence turns "same remainder on division by nn" into an algebraic equality that survives +,−,×+,-,\times.

Where this lives today

Modular arithmetic built on exactly these three laws (addition, subtraction, multiplication of congruences) underlies public-key cryptography: RSA encryption and decryption are congruence computations modulo a large composite number, and the correctness proof of RSA is a chain of congruence manipulations culminating in Euler's generalization of Fermat's Little Theorem. Check-digit schemes — ISBNs, credit card numbers (Luhn's algorithm), UPC barcodes — are direct applications of congruence arithmetic mod small numbers, catching single-digit and transposition errors by verifying that a weighted digit sum is congruent to a fixed value. In computer science, hash tables rely on congruence mod the table size to distribute keys, and modular arithmetic on fixed-width registers (mod 2322^{32} or 2642^{64}) is literally how integer overflow behaves in most programming languages — a direct, if unintentional, application of the ring structure proved above. In abstract algebra, this article's theorem is the concrete special case R=ZR = \mathbb{Z} of the general fact that congruence modulo an ideal is compatible with ring operations, which is how quotient rings are constructed. In signal processing and coding theory, cyclic redundancy checks (CRCs) treat data as coefficients of a polynomial and detect errors via congruence modulo a fixed generator polynomial, a direct descendant of the same additive/multiplicative compatibility proved here.

Ask the tutor: How do these three arithmetic laws combine to prove Fermat's Little Theorem?

DefinitionCongruence modulo nn

Let nn be a positive integer, and let a,b∈Za, b \in \mathbb{Z}. We say aa is congruent to bb modulo nn, written

a≡b(modn),a \equiv b \pmod{n},

if n∣(a−b)n \mid (a - b), that is, there exists an integer kk such that a−b=kna - b = kn. If n∤(a−b)n \nmid (a-b) we write a≢b(modn)a \not\equiv b \pmod n. Equivalently (a fact proved below using the Division Algorithm), a≡b(modn)a \equiv b \pmod n if and only if aa and bb leave the same remainder when divided by nn.

Intuition

Picture the integers laid out on a number line, then imagine gluing the line into a circle of circumference nn by identifying every point with the point nn units to its right. Two integers become congruent mod nn exactly when this gluing sends them to the same spot on the circle. This is precisely the "clock arithmetic" picture: a clock with nn hours glues 00 and nn together, and every integer lands on exactly one of the nn marks 0,1,…,n−10, 1, \dots, n-1. Concretely, fix n=5n = 5. The integers …,−8,−3,2,7,12,…\dots, -8, -3, 2, 7, 12, \dots all differ from each other by multiples of 55, so they are all congruent mod 55 — they all sit at the same mark on a 5-hour clock, namely the mark labeled 22 (since 22 is the remainder of each of these numbers upon division by 55). This clustering of Z\mathbb{Z} into five families, one for each possible remainder 0,1,2,3,40,1,2,3,4, is the geometric content of congruence, and it is exactly why congruence deserves to be called an equivalence relation: it partitions the integers into disjoint classes. The second key intuition is algebraic robustness. Congruence is not just a static partition; it is compatible with the operations that make Z\mathbb{Z} a ring. If two numbers are "the same" mod nn, then adding, subtracting, or multiplying them by anything congruent respects that sameness — the operations descend to the quotient. This is what makes modular arithmetic a genuine number system rather than a bookkeeping trick, and it is the theorem proved in detail below.

Figure
The five residue classes mod 5, wrapped onto a clock, and shown unrolled on the number line
0 1 2 3 4 clock mod 5 -3 2 7 12 all ≡ 2 (mod 5) unrolled onto ℤ
TheoremCongruence is an equivalence relation compatible with +,−,×+,-,\times

Let nn be a fixed positive integer. Then:

(0) Remainder characterization. For all a,b∈Za,b \in \mathbb{Z}, a≡b(modn)a \equiv b \pmod n if and only if aa and bb have the same remainder upon division by nn.

(1) Reflexivity. For every a∈Za \in \mathbb{Z}, a≡a(modn)a \equiv a \pmod n.

(2) Symmetry. For all a,b∈Za, b \in \mathbb{Z}, if a≡b(modn)a \equiv b \pmod n then b≡a(modn)b \equiv a \pmod n.

(3) Transitivity. For all a,b,c∈Za,b,c \in \mathbb{Z}, if a≡b(modn)a \equiv b \pmod n and b≡c(modn)b \equiv c \pmod n, then a≡c(modn)a \equiv c \pmod n. Consequently ≡(modn)\equiv \pmod n is an equivalence relation on Z\mathbb{Z}, partitioning it into equivalence classes (residue classes).

(4) Compatibility with addition and subtraction. If a≡b(modn)a \equiv b \pmod n and c≡d(modn)c \equiv d \pmod n, then

a+c≡b+d(modn)anda−c≡b−d(modn).a + c \equiv b + d \pmod n \qquad \text{and} \qquad a - c \equiv b - d \pmod n.

(5) Compatibility with multiplication. If a≡b(modn)a \equiv b \pmod n and c≡d(modn)c \equiv d \pmod n, then

ac≡bd(modn).ac \equiv bd \pmod n.

(6) Powers. If a≡b(modn)a \equiv b \pmod n, then for every integer k≥1k \geq 1, ak≡bk(modn)a^k \equiv b^k \pmod n.

Proof

We prove each part in turn using only the definition of congruence (n∣a−bn \mid a - b means a−b=kna - b = kn for some k∈Zk \in \mathbb{Z}) and the Division Algorithm, which states: for any integers aa and n>0n>0, there exist unique integers q,rq, r with a=qn+ra = qn + r and 0≤r<n0 \le r < n.

(0) Remainder characterization. (⇒\Rightarrow) Suppose a≡b(modn)a \equiv b \pmod n, so a−b=kna - b = kn for some integer kk. By the Division Algorithm write b=qn+rb = qn + r with 0≤r<n0 \le r < n. Then

a=b+kn=qn+r+kn=(q+k)n+r,a = b + kn = qn + r + kn = (q+k)n + r,

which exhibits a=q′n+ra = q'n + r with q′=q+kq' = q+k and the same remainder rr, 0≤r<n0 \le r < n. By the uniqueness clause of the Division Algorithm, the remainder of aa upon division by nn is also rr. Hence aa and bb have the same remainder. (⇐\Leftarrow) Suppose aa and bb have the same remainder rr upon division by nn: a=q1n+ra = q_1 n + r, b=q2n+rb = q_2 n + r, with 0≤r<n0 \le r < n. Subtracting,

a−b=(q1−q2)n,a - b = (q_1 - q_2) n,

so n∣(a−b)n \mid (a-b), i.e. a≡b(modn)a \equiv b \pmod n. This proves the equivalence.

(1) Reflexivity. For any aa, a−a=0=0⋅na - a = 0 = 0 \cdot n, so n∣(a−a)n \mid (a-a). Hence a≡a(modn)a \equiv a \pmod n.

(2) Symmetry. Suppose a≡b(modn)a \equiv b \pmod n, so a−b=kna - b = kn for some k∈Zk \in \mathbb{Z}. Then b−a=(−k)nb - a = (-k)n, and since −k-k is an integer, n∣(b−a)n \mid (b-a). Hence b≡a(modn)b \equiv a \pmod n.

(3) Transitivity. Suppose a≡b(modn)a \equiv b \pmod n and b≡c(modn)b \equiv c \pmod n. Then there exist integers k1,k2k_1, k_2 with

a−b=k1n,b−c=k2n.a - b = k_1 n, \qquad b - c = k_2 n.

Adding these two equations,

a−c=(a−b)+(b−c)=k1n+k2n=(k1+k2)n.a - c = (a-b) + (b-c) = k_1 n + k_2 n = (k_1+k_2) n.

Since k1+k2∈Zk_1 + k_2 \in \mathbb{Z}, we get n∣(a−c)n \mid (a - c), i.e. a≡c(modn)a \equiv c \pmod n. Parts (1)–(3) show ≡(modn)\equiv \pmod n is reflexive, symmetric, and transitive, hence an equivalence relation on Z\mathbb{Z}. A standard fact about equivalence relations (immediate from the definitions: reflexivity guarantees every element lies in some class, symmetry and transitivity guarantee two classes are either identical or disjoint) is that it partitions Z\mathbb{Z} into disjoint equivalence classes; by part (0) these classes are exactly the sets of integers sharing a common remainder r∈{0,1,…,n−1}r \in \{0, 1, \dots, n-1\}, so there are exactly nn of them.

(4) Compatibility with addition and subtraction. Suppose a≡b(modn)a \equiv b \pmod n and c≡d(modn)c \equiv d \pmod n. Then there exist integers k1,k2k_1, k_2 with

a−b=k1n,c−d=k2n.a - b = k_1 n, \qquad c - d = k_2 n.

Addition: Adding these,

(a+c)−(b+d)=(a−b)+(c−d)=k1n+k2n=(k1+k2)n,(a+c) - (b+d) = (a-b) + (c-d) = k_1 n + k_2 n = (k_1 + k_2) n,

and since k1+k2∈Zk_1+k_2 \in \mathbb{Z}, n∣((a+c)−(b+d))n \mid \big((a+c)-(b+d)\big), so a+c≡b+d(modn)a + c \equiv b + d \pmod n. Subtraction: Subtracting instead,

(a−c)−(b−d)=(a−b)−(c−d)=k1n−k2n=(k1−k2)n,(a-c) - (b-d) = (a-b) - (c-d) = k_1 n - k_2 n = (k_1 - k_2) n,

and since k1−k2∈Zk_1 - k_2 \in \mathbb{Z}, n∣((a−c)−(b−d))n \mid \big((a-c)-(b-d)\big), so a−c≡b−d(modn)a - c \equiv b - d \pmod n.

(5) Compatibility with multiplication. Again let a−b=k1na - b = k_1 n and c−d=k2nc - d = k_2 n with k1,k2∈Zk_1, k_2 \in \mathbb{Z}, so a=b+k1na = b + k_1 n and c=d+k2nc = d + k_2 n. Then

ac=(b+k1n)(d+k2n)=bd+bk2n+dk1n+k1k2n2.ac = (b + k_1 n)(d + k_2 n) = bd + b k_2 n + d k_1 n + k_1 k_2 n^2.

Hence

ac−bd=n(bk2+dk1+k1k2n).ac - bd = n\left(b k_2 + d k_1 + k_1 k_2 n\right).

The quantity in parentheses, bk2+dk1+k1k2nb k_2 + d k_1 + k_1 k_2 n, is an integer (a sum of products of integers), so n∣(ac−bd)n \mid (ac - bd), i.e. ac≡bd(modn)ac \equiv bd \pmod n.

(6) Powers. We induct on kk. The base case k=1k=1 is the hypothesis a≡b(modn)a \equiv b \pmod n itself. For the inductive step, suppose ak≡bk(modn)a^k \equiv b^k \pmod n for some k≥1k \ge 1 (inductive hypothesis). We are also given a≡b(modn)a \equiv b \pmod n. Applying part (5) with the pair (ak,bk)(a^k, b^k) in place of (a,c)(a,c) and (a,b)(a,b) in place of (c,d)(c,d) — that is, multiplying the two congruences ak≡bk(modn)a^k \equiv b^k \pmod n and a≡b(modn)a \equiv b \pmod n — gives

ak⋅a≡bk⋅b(modn),i.e.ak+1≡bk+1(modn).a^k \cdot a \equiv b^k \cdot b \pmod n, \qquad \text{i.e.} \qquad a^{k+1} \equiv b^{k+1} \pmod n.

By induction, ak≡bk(modn)a^k \equiv b^k \pmod n holds for every integer k≥1k \ge 1. ■\blacksquare

∎

Worked examples

Example 1 — a digit-sum divisibility test, proved from the theorem, with an asymmetric number. Claim: N=4,186,935N = 4{,}186{,}935 is divisible by 99 if and only if the sum of its decimal digits is divisible by 99; verify this for NN and find N  9N \bmod 9. Write NN in decimal as N=∑i=0mdi 10iN = \sum_{i=0}^{m} d_i \, 10^i where di∈{0,…,9}d_i \in \{0, \dots, 9\} are the digits (d0d_0 the units digit, etc.). Here N=4,186,935N = 4{,}186{,}935, so reading digits from the units place:

d0=5, d1=3, d2=9, d3=6, d4=8, d5=1, d6=4.d_0 = 5,\ d_1=3,\ d_2=9,\ d_3=6,\ d_4=8,\ d_5=1,\ d_6=4.

Check: 4⋅106+1⋅105+8⋅104+6⋅103+9⋅102+3⋅10+5=4,186,9354\cdot10^6+1\cdot10^5+8\cdot10^4+6\cdot10^3+9\cdot10^2+3\cdot10+5 = 4{,}186{,}935. Good. First, note 10≡1(mod9)10 \equiv 1 \pmod 9, since 10−1=910 - 1 = 9. By part (6) of the theorem (powers), 10i≡1i=1(mod9)10^i \equiv 1^i = 1 \pmod 9 for every i≥0i \ge 0 (and trivially for i=0i=0 by reflexivity). By part (5) applied repeatedly (multiplying di≡di(mod9)d_i \equiv d_i \pmod 9 with 10i≡1(mod9)10^i \equiv 1 \pmod 9), we get

di⋅10i≡di⋅1=di(mod9)for each i.d_i \cdot 10^i \equiv d_i \cdot 1 = d_i \pmod 9 \quad \text{for each } i.

Now apply part (4) (addition) repeatedly across all i=0,…,mi = 0, \dots, m to sum these congruences:

N=∑i=0mdi10i≡∑i=0mdi(mod9).N = \sum_{i=0}^m d_i 10^i \equiv \sum_{i=0}^m d_i \pmod 9.

So NN is congruent mod 99 to its digit sum S=∑diS = \sum d_i; in particular N≡0(mod9)  ⟺  S≡0(mod9)N \equiv 0 \pmod 9 \iff S \equiv 0 \pmod 9, which is exactly the classical rule. Now compute for our number: digit sum

S=4+1+8+6+9+3+5=36.S = 4+1+8+6+9+3+5 = 36.

Since 3+6=93+6=9 and 99 is divisible by 99, we get S≡0(mod9)S \equiv 0 \pmod 9, hence 36≡0(mod9)36 \equiv 0 \pmod 9, hence by the congruence just derived, N≡0(mod9)N \equiv 0 \pmod 9. So N=4,186,935N = 4{,}186{,}935 is divisible by 99. (Direct check: 4,186,935/9=465,2154{,}186{,}935 / 9 = 465{,}215, an integer — confirms the claim.) Moreover, since S=36≡0(mod9)S = 36 \equiv 0 \pmod 9, we conclude N  9=0N \bmod 9 = 0, illustrating that the remainder of NN mod 99 equals the remainder of its digit sum mod 99, not just a divisibility yes/no answer — a strictly stronger statement that follows from the same congruence N≡S(mod9)N \equiv S \pmod 9.

Example 2 — computing a large power's remainder using compatibility with multiplication and powers. Find the remainder when 7557^{55} is divided by 1313, without computing 7557^{55} directly. We repeatedly use parts (5) and (6) to reduce the exponent's growth. First compute small powers of 77 mod 1313:

71≡7(mod13).7^1 \equiv 7 \pmod{13}.
72=49=3⋅13+10≡10≡−3(mod13).7^2 = 49 = 3\cdot 13 + 10 \equiv 10 \equiv -3 \pmod{13}.

So 72≡−3(mod13)7^2 \equiv -3 \pmod{13}. By part (6), raising both sides to the 4th power (i.e. applying powers to the congruence 72≡−37^2 \equiv -3),

78=(72)4≡(−3)4=81(mod13).7^8 = (7^2)^4 \equiv (-3)^4 = 81 \pmod{13}.

Now reduce 8181: 81=6⋅13+381 = 6\cdot 13 + 3, so 81≡3(mod13)81 \equiv 3 \pmod{13}, giving

78≡3(mod13).7^8 \equiv 3 \pmod{13}.

Next, write 55=8⋅6+755 = 8 \cdot 6 + 7, i.e. 755=(78)6⋅77=(78)6⋅72⋅757^{55} = (7^8)^6 \cdot 7^7 = (7^8)^6 \cdot 7^2 \cdot 7^5; to keep this elementary and fully justified by parts (5)/(6) alone, we instead build up directly. By part (6), from 78≡3(mod13)7^8 \equiv 3 \pmod{13} we get (78)6≡36(mod13)(7^8)^6 \equiv 3^6 \pmod{13}. Compute 363^6 stepwise mod 1313 using part (5) repeatedly:

32=9,33=27≡27−2⋅13=1(mod13).3^2 = 9, \quad 3^3 = 27 \equiv 27-2\cdot13=1 \pmod{13}.

So 33≡1(mod13)3^3 \equiv 1 \pmod{13}, and by part (6), (33)2=36≡12=1(mod13)(3^3)^2 = 3^6 \equiv 1^2 = 1 \pmod{13}. Thus (78)6≡1(mod13)(7^8)^6 \equiv 1 \pmod{13}, i.e. 748≡1(mod13)7^{48} \equiv 1 \pmod{13}. Now 55=48+755 = 48 + 7, so 755=748⋅777^{55} = 7^{48}\cdot 7^{7}. By part (5) (multiplying the congruences 748≡17^{48}\equiv 1 and 77≡777^7 \equiv 7^7),

755≡1⋅77=77(mod13).7^{55} \equiv 1 \cdot 7^7 = 7^7 \pmod{13}.

Finally compute 77  137^7 \bmod 13 using the values already found: 72≡−37^2 \equiv -3, so by part (6) 74=(72)2≡(−3)2=9(mod13)7^4 = (7^2)^2 \equiv (-3)^2 = 9 \pmod{13}, and 76=74⋅72≡9⋅(−3)=−27≡−27+3⋅13=12≡−1(mod13)7^6 = 7^4\cdot 7^2 \equiv 9 \cdot(-3) = -27 \equiv -27+3\cdot13 = 12 \equiv -1 \pmod{13} (using part (5)). Then

77=76⋅7≡(−1)⋅7=−7≡6(mod13)7^7 = 7^6 \cdot 7 \equiv (-1)\cdot 7 = -7 \equiv 6 \pmod{13}

(using part (5) again, and −7+13=6-7 + 13 = 6). Therefore 755≡6(mod13)7^{55} \equiv 6 \pmod{13}; the remainder of 7557^{55} upon division by 1313 is 6\boxed{6}. Every step used only reflexivity, and parts (4)–(6) of the theorem — never a direct evaluation of 7557^{55} itself, which has 47 digits.

Counterexamplewhy "gcd⁡(c,n)=1\gcd(c,n)=1" is needed for cancellation — dropping it breaks a division law

The theorem carefully proves that congruences can be added, subtracted, and multiplied — it says nothing about dividing or cancelling a common factor. One might hope for a converse to multiplicative compatibility: "if ac≡bc(modn)ac \equiv bc \pmod n then a≡b(modn)a \equiv b \pmod n." This is false in general; it requires the extra hypothesis gcd⁡(c,n)=1\gcd(c,n)=1 (a fact properly developed in Linear Congruences), and dropping that hypothesis produces genuine counterexamples. Take n=6n = 6, c=2c = 2, a=1a = 1, b=4b = 4. Then

ac=1⋅2=2,bc=4⋅2=8,ac = 1\cdot 2 = 2, \qquad bc = 4 \cdot 2 = 8,

and 8−2=68 - 2 = 6, so indeed

ac≡bc(mod6).ac \equiv bc \pmod 6.

But

a−b=1−4=−3,a - b = 1 - 4 = -3,

and 6∤−36 \nmid -3, so

a≢b(mod6).a \not\equiv b \pmod 6.

Here gcd⁡(c,n)=gcd⁡(2,6)=2≠1\gcd(c, n) = \gcd(2,6) = 2 \ne 1, which is exactly why cancellation fails: the "common factor" c=2c=2 shares a factor with the modulus n=6n=6, and that shared factor 22 is precisely what gets lost when passing from ac≡bcac\equiv bc back to a≡ba \equiv b. This shows the arithmetic laws proved above (addition, subtraction, multiplication, powers) are genuinely one-directional in the multiplicative case — they let you build up new true congruences from old ones, but they do not license cancelling a factor from both sides unless that factor is coprime to the modulus.

Scope, edge cases & common traps

SituationWhat holdsWhat can fail
n=1n=1Every integer is congruent to every other integer mod 11 (only one residue class)Congruence mod 1 carries no information
Negative a,ba,bDefinition and all proofs work unchanged (n∣a−bn \mid a-b makes sense for any integers)Forgetting negative remainders exist; always use 0≤r<n0 \le r < n from the Division Algorithm
Adding/subtracting congruencesAlways valid (Theorem parts 4)None — fully general
Multiplying congruencesAlways valid (Theorem part 5)None — fully general
Cancelling a common factor cc from ac≡bcac\equiv bcValid only if gcd⁡(c,n)=1\gcd(c,n)=1False in general — see counterexample above
Dividing both sides and the modulus by d=gcd⁡(c,n)d=\gcd(c,n)ac≡bc(modn)⇒a≡b(modn/d)ac\equiv bc \pmod n \Rightarrow a \equiv b \pmod{n/d}Easy to misstate as "mod nn" instead of "mod n/dn/d"

The mathematician behind it

Origins · 1 minCarl Friedrich Gauss and how this was discovered
CF
Carl Friedrich Gauss
1777–1855 · Germany, Duchy of Brunswick and Kingdom of Hanover

Gauss introduced the congruence notation a≡b(modn)a \equiv b \pmod n in his 1801 treatise Disquisitiones Arithmeticae, written when he was in his early twenties. He designed the notation deliberately to evoke ordinary equality, precisely because — as the theorem above shows — congruence really does obey addition, subtraction, and multiplication laws parallel to those of equality. Gauss used this apparatus to develop the theory of quadratic residues, prove the law of quadratic reciprocity, and lay the groundwork for what would become modern algebraic number theory. Beyond number theory, Gauss made foundational contributions to geometry, statistics (the normal distribution and least squares), astronomy (predicting the orbit of the dwarf planet Ceres), and magnetism; the CGS unit of magnetic flux density, the gauss, is named for him.

History
- 1777 — Carl Friedrich Gauss is born in Braunschweig (Brunswick).
- 1796 — At age 19, Gauss proves the constructibility of the regular 17-gon by straightedge and compass.
- 1801 — Gauss publishes Disquisitiones Arithmeticae, introducing the congruence notation ≡(modn)\equiv \pmod n and systematically developing its arithmetic.
- 1801 — Gauss also uses congruence-based methods to recompute and successfully predict the reappearance of Ceres.
- 1855 — Gauss dies in Göttingen, having shaped number theory, geometry, and statistics for the following two centuries.
What exactly does a≡b(modn)a \equiv b \pmod n mean, in the simplest terms?

It means nn divides the difference a−ba - b exactly, with no remainder. Equivalently, and more intuitively, it means aa and bb leave the same remainder when you divide each of them by nn — this equivalence is proved as part (0) of the theorem above using the Division Algorithm. For example, 17≡5(mod12)17 \equiv 5 \pmod{12} because 17−5=1217 - 5 = 12 is divisible by 1212, and indeed both 1717 and 55 leave remainder 55 when divided by 1212. This is the same idea as clock arithmetic: 17 o'clock and 5 o'clock are "the same time" on a 12-hour clock.

Is congruence the same thing as equality?

No, but it behaves remarkably like equality for addition, subtraction, and multiplication, which is exactly why Gauss chose a notation resembling "==". The crucial difference is that congruence forgets information: infinitely many integers (e.g. all of …,−19,−7,5,17,29,…\dots,-19,-7,5,17,29,\dots) are congruent to each other mod 1212, whereas equality distinguishes every integer from every other. Congruence is coarser than equality — it is equality "up to multiples of nn." Division is where the analogy with equality breaks most sharply: you cannot always cancel a common factor from a congruence, as the counterexample above demonstrates.

Can I always add, subtract, or multiply congruences freely, mixing different ones?

Yes — that is precisely the content of parts (4) and (5) of the theorem. If a≡b(modn)a \equiv b \pmod n and c≡d(modn)c \equiv d \pmod n (same modulus nn in both), then you may freely form a+c≡b+da+c \equiv b+d, a−c≡b−da - c\equiv b-d, and ac≡bdac \equiv bd, all still modulo nn. You may also raise both sides of a single congruence to any positive integer power. What you may not do in general is divide both sides by a common factor, or mix two congruences with different moduli into a single new congruence without extra justification (such as the Chinese Remainder Theorem, a separate result).

Why is congruence called an "equivalence relation," and why does that matter?

An equivalence relation is any relation satisfying reflexivity, symmetry, and transitivity, and the article's theorem proves congruence mod nn satisfies all three. This matters because equivalence relations automatically partition their underlying set into disjoint classes — no two distinct classes overlap, and every element belongs to exactly one class. For congruence mod nn, this partition has exactly nn classes, corresponding to remainders 0,1,…,n−10,1,\dots,n-1; this partition is called the set of Residue Classes and Complete Residue Systems, the natural next topic once congruence itself is understood.

Does congruence work the same way for negative integers?

Yes, completely unchanged. The definition n∣(a−b)n \mid (a-b) makes sense for any integers a,ba, b, positive, negative, or zero, and every proof above used only this definition together with the Division Algorithm, which also holds for negative aa (the remainder rr is still required to satisfy 0≤r<n0 \le r < n). For instance, −8≡2(mod5)-8 \equiv 2 \pmod 5 because −8−2=−10-8 - 2 = -10 is divisible by 55, and indeed −8=(−2)(5)+2-8 = (-2)(5) + 2 shows −8-8 has remainder 22 upon division by 55, matching the remainder of 22 itself.

How does this connect to Fermat's Little Theorem?

Fermat's Little Theorem states that if pp is prime and p∤ap \nmid a, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p. Its proof relies entirely on the arithmetic laws established here: multiplying congruences together, cancelling under the coprimality condition gcd⁡(a,p)=1\gcd(a,p)=1 (which is guaranteed when p∤ap \nmid a since pp is prime), and using the "powers" compatibility (part 6 above) to manipulate exponents. In other words, this article's theorem is the toolbox; Fermat's Little Theorem is one of its first spectacular applications, developed once residue systems are in place.

What's the difference between "mod" as in a mod na \bmod n (an operation returning a number) and "(modn)\pmod n" as in a congruence statement?

These are related but distinct uses. The expression a  na \bmod n (no parentheses, used as an operator) denotes the specific remainder rr with 0≤r<n0 \le r < n produced by the Division Algorithm applied to aa and nn — it is a single integer. The notation "a≡b(modn)a \equiv b \pmod n" (with parentheses around "mod nn") is a relation between two integers aa and bb, asserting n∣(a−b)n \mid (a-b); it is a true-or-false statement, not a number. Part (0) of the theorem links them: a≡b(modn)a \equiv b \pmod n if and only if a  n=b  na \bmod n = b \bmod n.

Before this

Where this leads