Arithmetic where numbers wrap around after reaching a fixed modulus.
IntuitionThe clock: numbers that wrap around
Look at a clock face. After 12 o'clock comes 1 again, not 13: the hours "wrap around" every 12 steps. If it is 9 o'clock now, 8 hours later it is not "17 o'clock" but 5 o'clock, because 17 and 5 leave the same remainder when divided by 12. This everyday wrapping is exactly the idea behind congruences: two integers are treated as "the same" if they differ by a multiple of a fixed number m, called the modulus. Congruences let us replace huge numbers by their remainders and still compute correctly — the engine behind clocks, calendars, check digits, hash tables, and modern cryptography.
A point moving around a circle divided into equal arcs, illustrating how remainders modulo m cycle back to the start.
On the modulo-m clock, chords connect each residue x to axmodm. Change m and a to watch when the map permutes all residues vs collapses onto a subgroup.
SchoolDefinition and basic properties
Definition: Congruence modulo m
Fix a positive integer m (the modulus). Two integers a and b are **congruent modulo m**, written a≡b(modm), when m divides their difference: m∣(a−b). Equivalently, a and b leave the same remainder when divided by m. All integers congruent to a fixed a form its residue class[a]={…,a−m,a,a+m,a+2m,…}, and there are exactly m distinct residue classes, written Z/mZ.
a≡b(modm)⟺m∣(a−b)
Here a,b,m are integers with m>0; the symbol ∣ reads "divides", and (modm) names the modulus attached to a congruence. This single definition already tells us that congruence is reflexive, symmetric, and transitive — an equivalence relation — which is why it makes sense to talk about "the residue classes modulo m" as objects in their own right, collected into the set Z/mZ={[0],[1],…,[m−1]}.
For a fixed modulus m: (i) a≡a(modm) for every a; (ii) a≡b(modm)⟹b≡a(modm); (iii) a≡b,b≡c(modm)⟹a≡c(modm); and if a≡b(modm) and c≡d(modm) then a+c≡b+d(modm) and ac≡bd(modm).
Why is it true?
This is what makes congruences usable as arithmetic: it means we can add, subtract, and multiply remainders directly instead of the huge original numbers, and always get the correct remainder back — the reason computers can check a 16-digit card number or compute 7100mod13 without ever storing a 100-digit number.
Proof
Reflexivity: a−a=0 and m∣0 for every m, so a≡a(modm).
Symmetry: if a≡b(modm) then a−b=mk for some integer k, so b−a=m(−k); since −k is also an integer, m∣(b−a), i.e. b≡a(modm).
Transitivity: if a≡b(modm) and b≡c(modm), write a−b=mk1 and b−c=mk2. Adding these, a−c=(a−b)+(b−c)=m(k1+k2), so m∣(a−c) and a≡c(modm).
Compatibility with addition: from a−b=mk1 and c−d=mk2, add the two equations: (a+c)−(b+d)=m(k1+k2), which is a multiple of m, so a+c≡b+d(modm).
Compatibility with multiplication: write ac−bd=ac−bc+bc−bd=c(a−b)+b(c−d)=c⋅mk1+b⋅mk2=m(ck1+bk2). This is again a multiple of m, so ac≡bd(modm). Together, (i)-(iii) make congruence an equivalence relation, and the last two steps show every ring operation on Z descends to a well-defined operation on residue classes Z/mZ.
If gcd(c,m)=1, then ac≡bc(modm),gcd(c,m)=1⟹a≡b(modm). Equivalently, c has a multiplicative inverse modulo m: an integer u with cu≡1(modm).
Why is it true?
Ordinary "division" is really multiplication by an inverse, and this theorem tells us exactly when that inverse exists modulo m: precisely when c shares no common factor with m. Without this condition cancellation genuinely fails (see the last row of the table above), which is why every later result about powers modulo m — Fermat's little theorem, Euler's theorem, the Chinese remainder theorem — is built on top of this single algebraic fact.
Proof
Since gcd(c,m)=1, Bézout's identity (a consequence of the Euclidean algorithm) guarantees ∃u,v∈Z:cu+mv=1: there exist integers u,v with cu+mv=1.
Multiply both sides of ac≡bc(modm) by u: acu≡bcu(modm). Now substitute cu=1−mv: the left side becomes a(1−mv)=a−amv, and since amv is a multiple of m, a(1−mv)≡a(modm); likewise the right side b(1−mv)≡b(modm). Hence a≡b(modm), proving cancellation.
Moreover, taking a=1,b=0,c=c is not needed — directly, cu=1−mv≡1(modm) by the same substitution, so u itself is the multiplicative inverse of c modulo m: this is exactly the object whose existence Theorem statement claims.
The hypothesis gcd(c,m)=1 is essential: take c=4,m=6 (so gcd(4,6)=2=1). Then 4×2=8≡2(mod6) and 4×5=20≡2(mod6), so 4×2≡4×5(mod6), yet 2≡5(mod6) — cancellation genuinely fails once the coprimality hypothesis is dropped.
AdvancedReal-World Applications and Worked Examples
Modular arithmetic is one of the most quietly ubiquitous tools in applied mathematics. Calendars use it to find the day of the week (mod 7); barcode and ISBN systems use it to catch typing errors with a single check digit (mod 11 or mod 10); hash tables in computer science map keys to buckets by taking a remainder; and RSA-style cryptography (covered in depth in the next two topics) encodes and decodes messages entirely through modular exponentiation. Two concrete examples below show the everyday reasoning behind the calendar and the check-digit applications.
Example: Finding the day of the week
If today is Tuesday, what day of the week will it be 100 days from now?
Solution
The days of the week repeat with period 7, so only the remainder of 100 upon division by 7 matters: 100=7×14+2, so 100≡2(mod7).
By the additive compatibility proved above, moving forward 100 days has the same effect modulo 7 as moving forward just 2 days: Tuesday +2 days is Thursday.
So 100 days from a Tuesday is a Thursday. Notice that we never had to count all 100 days one by one — congruence let us collapse a large number into its small, equivalent remainder.
Example: Verifying an ISBN-10 check digit
An ISBN-10 code d1d2⋯d10 is valid exactly when ∑i=110idi≡0(mod11). Check whether 0-306-40615-2 is a valid ISBN-10.
Solution
List the digits d1,…,d10=0,3,0,6,4,0,6,1,5,2 and form the weighted sum ∑idi=1(0)+2(3)+3(0)+4(6)+5(4)+6(0)+7(6)+8(1)+9(5)+10(2).
Compute each term: 0,6,0,24,20,0,42,8,45,20. Adding them: 0+6+0+24+20+0+42+8+45+20=165.
By the multiplicative and additive compatibility of congruence, we only need 165mod11: since 11×15=165, we get 165≡0(mod11). The check passes, so 0-306-40615-2is a valid ISBN-10. If a single digit were mistyped, the weighted sum would almost certainly fail to be ≡0(mod11), which is exactly why publishers use this scheme to catch data-entry errors automatically.
ResearchCongruences at the research frontier: residue systems in modern cryptography
Using the standard convention 0≤r<m, what is −17mod5?
If a≡4(mod9) and b≡7(mod9), what is abmod9?
If today is Tuesday, what day of the week is 50 days from now?
The cancellation law ac≡bc(modm)⟹a≡b(modm) is guaranteed to hold when: