Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Modulo






The Mathematics of Remainders

Division does not always come out even. When 1717 is divided by 55, the result is 33 with 22 left over. That leftover — the remainder — is not a loose end to discard. It carries information about the relationship between the two numbers, and an entire branch of arithmetic is built around extracting and using it.

Key Terms

Modulus— the fixed positive integer that defines the wrap-around point
Remainder— what is left after dividing by the modulus
Congruence— two integers sharing the same remainder modulo mm
Residue Class— the set of all integers sharing a given remainder

See All Arithmetic Definitions →


What is Modulo?

It is 9 o'clock. What time will it be in 17 hours?
Counting on goes past 12 and starts again. From 12 o'clock that is 9+17=269 + 17 = 26 hours, which is two full turns of the clock and then 22 hours more: 2 o'clock. The full turns do not matter — only what is left over after them.
Every count of hours lands on the clock at what is left after removing full turns of 12.
hours counted from 12 o'clockfull turns of 12hours left overthe clock shows
26222 o'clock
15133 o'clock
30266 o'clock
363012 o'clock
The clock remembers only the leftover. A count that is an exact number of turns, like 3636, lands back on 12 — a leftover of 00.
Removing whole groups and keeping the leftover is division with remainder.
The answer comes from the division equation that connects any integer aa to a divisor nn:
What is Modulo?
a=n⋅q+r,0≤r<na = n \cdot q + r, \qquad 0 \leq r < n
The integer qq is the quotient — how many complete copies of nn fit inside aa. The integer rr is the remainder — what remains after those copies are removed. Modulo gives rr.
The definition
For integers aa and n>0n > 0, a mod na \bmod n is the remainder left when aa is divided by nn: the rr in a=n⋅q+ra = n \cdot q + r with 0≤r<n0 \leq r < n.
The modulo operation takes two integers and returns the remainder of their division. Given integers aa and nn (with n>0n > 0), "a mod na \bmod n" answers one question: what is left over when aa is divided by nn?
So 26 mod 12=226 \bmod 12 = 2, and 9 o'clock plus 17 hours is 2 o'clock.
Modulo is an operation, like + or ×: two numbers in, one number out.
The expression 17 mod 5=217 \bmod 5 = 2 because 17=5⋅3+217 = 5 \cdot 3 + 2. Three complete groups of 55 account for 1515, leaving 22.
The expression 23 mod 7=223 \bmod 7 = 2 because 23=7⋅3+223 = 7 \cdot 3 + 2. Three complete groups of 77 account for 2121, leaving 22.
The expression 12 mod 4=012 \bmod 4 = 0 because 12=4⋅3+012 = 4 \cdot 3 + 0. The division is exact — nothing remains.
DownloadPNG2×PDF
Layout
anq (quotient)r = a mod nIdentity check (a = n · q + r)
1753217 = 5 · 3 + 2 ✓
2373223 = 7 · 3 + 2 ✓
1243012 = 4 · 3 + 0 ✓ (exact division)
What is Modulo?Learn Math Class
1234567891011121314151617★ 012345mod 6
Counting round a wheel of 6: the remainder is the slot you land on

The integers 1, 2, 3, … are placed one after another round a wheel with six slots, so 6 lands back on slot 0, 7 on slot 1, and every number lands on the slot equal to its remainder on division by 6. That slot is a mod 6. Count round the wheel for any modulus on the modular arithmetic wheel.

Modulo is the arithmetic of the slot, not of the number.
For positive numbers the answer is always between 0 and n − 1; for negative numbers two conventions give different answers.
(−7) mod 3(-7) \bmod 3 comes out as −1-1 under one convention and 22 under the other, and programming languages disagree about which to use. The difference is explained in negative dividends.
The rest of the page covers notation, modulo and divisibility, the range of remainders, computing a remainder, edge cases, negative dividends, congruence and its properties, the clock analogy, and why modulo matters.

Modulo Notation

Notation

Modulo Notation

One word, three costumes: the infix operator that computes, the percent sign machines prefer, and the triple-bar statement that merely claims. Telling the computation from the claim is the page's founding distinction. Both LaTeX spellings — \bmod and \pmod — are catalogued among the arithmetic symbols; see the LaTeX reference.
The divides bar behind every exact-division statement is owned by divisibility notation; the negative-dividend convention split lives on its own page.
a mod na \bmod n
a mod n; a modulo n
The infix operator that computes: 17 mod 5=217 \bmod 5 = 2 — a number out, every time, drawn from {0,1,…,n−1}\{0, 1, \ldots, n-1\} as The Range of Remainders below fixes. What is Modulo? above grounds it in the division equation a=nq+ra = nq + r.
CasesZero remainder is the divisibility bridge — a mod n=0a \bmod n = 0 exactly when n∣an \mid a, the two-dialect fact of Modulo and Divisibility below.
Do not confuseThe other spoken "mod". Complex numbers read ∣z∣|z| aloud as "mod z" — modulus as magnitude, no remainder anywhere; the shared syllable is an accident of Latin.
a % na \ \% \ n
a percent n — the remainder operator in code
The machine spelling: C, Java, Python, JavaScript and nearly every language compute remainders with % — same operation, different glyph. The mathematical page and the program disagree only in costume.
CasesLanguages disagree on negative dividends — (-7) % 3 returns −1-1 in some, 22 in others; the negative numbers page maps the two conventions and the universal repair idiom.
Do not confuseA percentage. The glyph's day job is per-hundred — 50%50\% of something — and its remainder career exists only between two operands in code; a%na \% n never means a fraction of nn.
a≡b(modn)a \equiv b \pmod{n}
a is congruent to b modulo n
The statement, not the computation: the triple bar claims aa and bb leave the same remainder — true or false, no number produced. The parenthesized modulus trails the whole claim; Congruence below develops the relation in full.
CasesThe grammar split is the working skill: a mod na \bmod n appears inside computations, ≡(modn)\equiv \pmod{n} inside proofs and rules — the modular identities behind divisibility rules are all written in the second dialect.
Do not confuseThe identity triple-bar. Elsewhere ≡\equiv means "identically equal" — f(x)≡0f(x) \equiv 0 holding for every xx — with no modulus in sight; the trailing (modn)\pmod{n} is what selects the congruence reading.
DownloadPNG2×PDF
Notation · Cheat sheet
Arithmetic Notation at a Glance
The marks from the notation cards across the arithmetic pages: how each is read and what it means. Every group links to the full card on its page.
Fractions
ab\frac{a}{b}
a over b
The vinculum: numerator over denominator, a division held in place.
a/ba/b
a slash b; a over b
The inline spelling for running text and code; same value, no grouping power.
a÷ba \div b
a divided by b
The obelus, the schoolroom division sign: a÷b=aba \div b = \frac{a}{b}.
Mixed numbers
2342\frac{3}{4}
two and three quarters
Adjacency means addition here, and only here: 2+342 + \frac{3}{4}.
3543\frac{5}{4} vs 4144\frac{1}{4}
non-standard form, and its correction
The fractional part must be proper; carry the extra whole.
−234-2\frac{3}{4}
negative two and three quarters
The minus grips the whole package: −(2+34)-(2 + \frac{3}{4}).
Divisibility
a∣ba \mid b
a divides b
A statement, true or false: b=a⋅kb = a \cdot k for some integer kk.
5∤125 \nmid 12
five does not divide twelve
The slashed bar denies: no integer kk gives 12=5k12 = 5k.
b mod a=0b \bmod a = 0
b mod a equals zero
The same fact as a computation: the remainder vanishes.
Factors
n=p1a1⋯pkakn = p_1^{a_1} \cdots p_k^{a_k}
n as a product of prime powers
Canonical factorisation: pp for primes, exponents count repeats.
d(n)d(n) · τ(n)\tau(n)
d of n; tau of n
The number of positive divisors of nn.
σ(n)\sigma(n)
sigma of n
The sum of the positive divisors: σ(12)=28\sigma(12) = 28.
GCD
gcd⁡(a,b)\gcd(a, b)
the g-c-d of a and b
Greatest common divisor, in function spelling.
HCF, GCF\text{HCF, GCF}
highest, or greatest, common factor
Other names for the gcd: HCF in British and Indian schools, GCF in American schools.
gcd⁡(a,b)=1\gcd(a, b) = 1
a and b are coprime
The equation is the notation; coprimality has no mark of its own.
LCM
lcm⁡(a,b)\operatorname{lcm}(a, b)
the l-c-m of a and b
Least common multiple, the mirror twin of gcd⁡\gcd.
[a,b][a, b]
bracket a, b
Number theory’s shorthand for the lcm; (a,b)(a, b) is the gcd.
LCM vs LCD\text{LCM vs LCD}
least common multiple; least common denominator
The LCD of fractions is the LCM of their denominators.
ModuloThis page
a mod na \bmod n
a mod n
The operator that computes a remainder: 17 mod 5=217 \bmod 5 = 2.
a % na \ \% \ n
a percent n
The remainder operator in code: C, Java, Python, JavaScript.
a≡b(modn)a \equiv b \pmod{n}
a is congruent to b modulo n
A statement: aa and bb leave the same remainder.
Integer part
⌊x⌋\lfloor x \rfloor
floor of x
The greatest integer at most xx: the integer part.
⌈x⌉\lceil x \rceil
ceiling of x
The least integer at least xx.
{x}\{x\}
fractional part of x
What the floor leaves: x−⌊x⌋x - \lfloor x \rfloor, in [0,1)[0, 1).
⌊x+12⌋\lfloor x + \tfrac{1}{2} \rfloor
x rounded to the nearest integer
Rounding built from the floor; ties go up: 2.5→32.5 \to 3.
Same marks, different job
a∣ba \mid bDivides, between integers; such that, inside set braces; absolute value when doubled.
(a,b)(a, b) vs [a,b][a, b]The gcd and the lcm in number-theory shorthand; a point or an interval elsewhere.
{x}\{x\}The fractional part here; a one-element set in set theory.
 mod \bmod vs (modn)\pmod{n}An operator that returns a number; a label on a congruence statement.
σ(n)\sigma(n)The divisor sum here; a standard deviation in statistics.
Arithmetic Notation at a Glance·/arithmeticLearn Math Class

Modulo and Divisibility

Modulo and divisibility are two sides of the same coin. Divisibility asks whether one integer divides another exactly. Modulo computes the evidence.

RULE
When a mod n=0a \bmod n = 0, the remainder vanishes — nn divides aa with nothing left over.

In divisibility notation, n∣an \mid a. The statement 24 mod 6=024 \bmod 6 = 0 and the statement 6∣246 \mid 24 express identical facts in different languages.

When a mod n≠0a \bmod n \neq 0, the remainder is positive — nn does not divide aa exactly. The statement 25 mod 6=125 \bmod 6 = 1 tells us 6∤256 \nmid 25, and it tells us by how much the division misses.

Divisibility is the concept — the yes-or-no question of whether one number fits evenly into another. Modulo is the computational tool — it answers the question and, when the answer is no, quantifies the shortfall.
DownloadPNG2×PDF
Two sides of the same coin
Divisibility asks whether one integer divides another exactly. Modulo computes the evidence: the remainder answers the question.
Modulo and divisibility
a mod na \bmod n
split by whether the remainder is 00
✓
Case 1
a mod n=0a \bmod n = 0
nn divides aa
the remainder vanishes: nn divides aa with nothing left over
n∣an \mid a
e.g.24 mod 6=024 \bmod 6 = 0, so 6∣246 \mid 24
✗
Case 2
a mod n≠0a \bmod n \neq 0
nn does not divide aa
the remainder is positive and tells by how much the division misses
n∤an \nmid a
e.g.25 mod 6=125 \bmod 6 = 1, so 6∤256 \nmid 25
Takeaway
Divisibility is the yes-or-no question; modulo is the tool that answers it and, when the answer is no, quantifies the shortfall.
Modulo and divisibility: is the remainder zero?·/arithmetic/moduloLearn Math Class

The Range of Remainders

RULE
For a fixed divisor nn, the remainder a mod na \bmod n is always one of the values {0,1,2,…,n−1}\{0, 1, 2, \ldots, n-1\}.

There are exactly nn possibilities, and no remainder can reach nn itself — if it did, another complete copy of nn could be extracted.

When n=2n = 2, every integer produces a remainder of 00 or 11. This is the basis of even and odd: even numbers give 00, odd numbers give 11.

When n=10n = 10, every integer produces a remainder between 00 and 99. For a non-negative number, that remainder is its last digit — 347 mod 10=7347 \bmod 10 = 7, read directly from the ones place.

Fact: Why some ISBNs end in X
The last character of a 10-digit ISBN makes 10d1+9d2+…+1⋅d1010d_1 + 9d_2 + \ldots + 1 \cdot d_{10} divisible by 1111, so it can take any of the eleven values 00 to 1010, and 1010 is written X. Since 1111 is prime, the check catches every single wrong digit and every swap of two digits.

When n=11n = 11, the possible remainders run from 00 to 1010: eleven values, one more than there are decimal digits. Every one of them except the last fits in a single digit place, but a remainder of 1010 needs two. A one-character code built on division by 1111 has to borrow an extra symbol for that case.

When n=7n = 7, every integer maps to one of seven remainders: {0,1,2,3,4,5,6}\{0, 1, 2, 3, 4, 5, 6\}. No matter how large the dividend grows — thousands, millions, billions — the remainder when divided by 77 never escapes this set.

The modulo operation compresses the entire number line into a finite set of nn values, repeating in cycles. Every integer lands somewhere in {0,1,…,n−1}\{0, 1, \ldots, n-1\}, and infinitely many integers share each landing spot.
DownloadPNG2×PDF
Layout
Modulus nRemainder set {0, 1, …, n−1}Natural interpretation
2{0, 1}parity — 0 for even, 1 for odd
7{0, 1, 2, 3, 4, 5, 6}day-of-week index from a starting reference day
10{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}the last digit of the decimal representation of the number
The Range of RemaindersLearn Math Class
123456789101112131415161718192021222324252627282930313233343536★ 012345mod 6
Six slots, six possible remainders: 0 to 5

The wheel has exactly six slots and every integer lands in one of them, so there are exactly six possible remainders mod 6, from 0 to 5, and none can equal 6 itself: that would be slot 0 again. The slots are the complete set of residues. Change the modulus and count the slots on the modular arithmetic wheel.

Whatever the size of a, its remainder is one of these few values.

How to Compute a Remainder

To find a mod na \bmod n, divide aa by nn, discard the fractional part of the quotient, multiply back, and subtract. The gap between the original number and the nearest multiple of nn at or below it is the remainder.

Example
For 47 mod 547 \bmod 5: divide 47÷5=9.447 \div 5 = 9.4. The integer part is 99. Multiply back: 9×5=459 \times 5 = 45. Subtract: 47−45=247 - 45 = 2. The remainder is 22.

Example
For 123 mod 7123 \bmod 7: divide 123÷7=17.57…123 \div 7 = 17.57\ldots. The integer part is 1717. Multiply back: 17×7=11917 \times 7 = 119. Subtract: 123−119=4123 - 119 = 4. The remainder is 44.

Pitfall: Reading the decimal part as the remainder
Taking the 44 in 47÷5=9.447 \div 5 = 9.4 as the remainder gives 47 mod 5=447 \bmod 5 = 4. The 0.40.4 is a fraction of 55, not a count of units: 0.4⋅5=20.4 \cdot 5 = 2, so 47 mod 5=247 \bmod 5 = 2.

The decimal quotient is only a step on the way to the answer. Its integer part counts the complete copies of nn inside aa, and multiplying back turns that count into the largest multiple of nn that fits. Only the subtraction measures the leftover in whole units, and that whole-number leftover is what modulo returns.

The procedure has a compact formula using the floor function ⌊x⌋\lfloor x \rfloor, which gives the greatest integer less than or equal to xx:

How to Compute a Remainder
a mod n=a−n⋅⌊an⌋a \bmod n = a - n \cdot \left\lfloor \frac{a}{n} \right\rfloor

This captures the three-step process in a single expression: divide, truncate to an integer, subtract the product.

The floor function, and why it differs from dropping the decimals when the quotient is negative, is covered on the integer and fractional part page.

To get the remainder for any pair of numbers instantly, use the modulo calculator.
The four moves on the first example of this section. Press Next to carry out one step at a time.
DownloadPNG2×PDF
47 mod 547 \bmod 5Step 1 of 4
Step
47 mod 547 \bmod 5
1
Divide aa by nn
47÷5=9.447 \div 5 = 9.4
2
Keep the integer part of the quotient
99
3
Multiply back by nnThe largest multiple of nn that fits
9×5=459 \times 5 = 45
4
Subtract from aaThe leftover is the remainder
47−45=247 - 45 = 2
Computing a remainder, step by step·/arithmetic/moduloLearn Math Class
Number line scene (single track)0510152025303540455047+5+5+5+5+5+5+5+5+5remainder = 247 = 5 · 9 + 247 ÷ 5 = 9.4, keep 99 jumps of 5 reach 4547 mod 5 = 2
Finding 47 mod 5 on a number line

Jumps of 5 from 0 land on 5, 10, 15, …, 45. A tenth jump would reach 50, past 47, so only 9 jumps fit: that is the integer part of 47 ÷ 5 = 9.4. The nearest multiple of 5 at or below 47 is 9 · 5 = 45, and the gap from 45 to 47 is the remainder: 47 mod 5 = 2.

The remainder is always the gap to the last multiple at or below a, so it stays between 0 and 4.

Edge Cases

Three cases deserve attention before the operation is applied routinely.

When 0≤a<n0 \leq a < n, the divisor exceeds the dividend and fits zero times. The entire value of aa is the remainder: 3 mod 10=33 \bmod 10 = 3, 0 mod 5=00 \bmod 5 = 0, 6 mod 7=66 \bmod 7 = 6. If 0≤a<n0 \leq a < n, then a mod n=aa \bmod n = a — the number already lies within the remainder set and needs no reduction.

Pitfall: Giving the quotient instead of the remainder
Answering 3 mod 10=03 \bmod 10 = 0, because 1010 fits into 33 zero times, reports the quotient. Modulo asks for what is left over, and all of 33 is left: 3 mod 10=33 \bmod 10 = 3.

Here the division equation takes the form a=n⋅0+aa = n \cdot 0 + a. The quotient is 00 because no complete copy of nn fits, and nothing is taken away from aa before the remainder is read. The two parts of the equation say different things: the quotient that nn is too large to fit even once, the remainder how much of aa is left over.

When n=1n = 1, every integer is a multiple of 11, so the remainder is always 00. The expression a mod 1=0a \bmod 1 = 0 for any integer aa. The remainder set {0,1,…,n−1}\{0, 1, \ldots, n-1\} collapses to {0}\{0\}.

When n=0n = 0, the operation is undefined. Division by zero has no meaning, and "the remainder when dividing by zero" inherits that meaninglessness. Every qq satisfies a=0⋅q+ra = 0 \cdot q + r with r=ar = a, because 0⋅q=00 \cdot q = 0 regardless of qq, so the quotient is not unique, and no remainder can satisfy 0≤r<00 \leq r < 0. In programming, a%  0a \% \; 0 has no valid result: Python raises an error, C leaves the behavior undefined, and JavaScript returns NaN\texttt{NaN}.
One row per edge case of a mod na \bmod n. Click a row for the reason behind it.
DownloadPNG2×PDF
General
a=n⋅q+r,0≤r<na = n \cdot q + r, \quad 0 \leq r < n
a mod n=ra \bmod n = r
Where the modulo rule changesLearn Math Class
Each row is the division equation a=n⋅q+ra = n \cdot q + r read at an extreme value of aa or nn.

Negative Dividends

Everything above assumes aa is non-negative. When the dividend is negative, the meaning of "remainder" splits — two conventions exist, each producing a different answer to the same question.

The expression (−7) mod 3(-7) \bmod 3 equals −1-1 under one convention and 22 under another. Both satisfy the division equation a=n⋅q+ra = n \cdot q + r; they differ in how the quotient qq is rounded, which forces different values of rr.

The distinction matters in practice because different programming languages adopt different conventions — code that works correctly in Python may produce different results in Java or JavaScript for the same negative input.

The full treatment — both conventions, their rationale, language-specific behavior, and conversion between them — is on the negative numbers page.
Learn More

Congruence

When two integers share the same remainder under division by nn, they are called congruent modulo nn. The notation is:

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

This reads "a is congruent to b modulo n" and means a mod n=b mod na \bmod n = b \bmod n — both numbers land on the same remainder.

The expression 17≡5(mod12)17 \equiv 5 \pmod{12} holds because 17 mod 12=517 \bmod 12 = 5 and 5 mod 12=55 \bmod 12 = 5. Both leave a remainder of 55 when divided by 1212.

The expression 23≡2(mod7)23 \equiv 2 \pmod{7} holds because 23 mod 7=223 \bmod 7 = 2 and 2 mod 7=22 \bmod 7 = 2. Both leave a remainder of 22.

Pitfall: Confusing mod with congruence
Writing 17 mod 5=717 \bmod 5 = 7 because 17≡7(mod5)17 \equiv 7 \pmod{5} treats the relation as the operation. The value of 17 mod 517 \bmod 5 is one number in {0,1,2,3,4}\{0, 1, 2, 3, 4\}: 17 mod 5=217 \bmod 5 = 2, while 17≡7(mod5)17 \equiv 7 \pmod{5} is a true statement.

An equivalent way to test congruence: a≡b(modn)a \equiv b \pmod{n} if and only if n∣(a−b)n \mid (a - b) — their difference is divisible by nn. For the first example, 17−5=1217 - 5 = 12, and 12∣1212 \mid 12. For the second, 23−2=2123 - 2 = 21, and 7∣217 \mid 21.

Congruence is not a new operation. It is a way of saying "same remainder" — a relationship between two numbers with respect to a shared divisor.
123456789101112131415161718192021222324252627282930313233343536★ 012345mod 6
One slot holds 3, 9, 15, …: a congruence class

Every number that lands in the same slot shares the same remainder, and those numbers are congruent modulo 6: the slot is the congruence class, and 3 ≡ 9 ≡ 15 (mod 6) is the statement that they sit together. Congruence is equality of slots. Highlight a class and read its members on the modular arithmetic wheel.

The properties in the next section are the rules of working with slots instead of numbers.

Properties of Congruence

Congruence modulo nn behaves like equality in several important ways. Three properties establish it as an equivalence relation — a formal notion of "sameness" within the modular world.

Reflexive: every integer is congruent to itself. a≡a(modn)a \equiv a \pmod{n} for any aa and nn, because a−a=0a - a = 0 and n∣0n \mid 0.

Symmetric: if a≡b(modn)a \equiv b \pmod{n}, then b≡a(modn)b \equiv a \pmod{n}. If nn divides a−ba - b, it also divides b−ab - a.

Transitive: 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}. If nn divides both a−ba - b and b−cb - c, it divides their sum (a−b)+(b−c)=a−c(a - b) + (b - c) = a - c.

These properties mean congruence partitions the integers into groups — called congruence classes — where every integer in a group shares the same remainder. For n=3n = 3, the integers split into three classes: those with remainder 00 (multiples of 33), those with remainder 11, and those with remainder 22. Every integer belongs to exactly one class.
Congruence mod nn behaves like equality and sorts every integer into exactly one of nn remainder classes.

The Clock Analogy

A 1212-hour clock is modular arithmetic made physical. After 1212 o'clock comes 11 o'clock, not 1313 — the numbers wrap around.

Pitfall: Writing the modulus instead of 0
Reading the dial gives 24 mod 12=1224 \bmod 12 = 12, since the hand points at 1212. A remainder is always less than 1212: 24=12⋅2+024 = 12 \cdot 2 + 0, so 24 mod 12=024 \bmod 12 = 0, the position the dial labels 1212.

The time 15:0015{:}00 on a 2424-hour clock translates to 3:003{:}00 on a 1212-hour clock: 15 mod 12=315 \bmod 12 = 3. The time 2727 hours from midnight is 3:003{:}00 AM: 27 mod 12=327 \bmod 12 = 3. Different numbers, same position on the dial.

Days of the week follow the same pattern with n=7n = 7. Starting from Sunday (00), day 1010 of a sequence falls on the same weekday as day 33: 10 mod 7=310 \bmod 7 = 3, which is Wednesday. Day 1717 is also Wednesday. Day 2424 is Wednesday again. The cycle repeats every 77 days.

Fact: The 13th is most often a Friday
Over the 48004800 months of a 400400-year cycle, the 13th falls on a Friday 688688 times, more than on any other weekday. The cycle is 146,097146{,}097 days, exactly 20,87120{,}871 weeks, so the same uneven pattern repeats forever.

The calendar runs the same count on a larger scale. The weekday of a date moves forward by 365 mod 7=1365 \bmod 7 = 1 from one year to the next, and by 22 after a leap day. Leap years follow a rule that only repeats after 400400 years: every fourth year, except century years not divisible by 400400. Whether the weekdays themselves repeat after that comes down to one remainder, the number of days in 400400 years taken mod 77.

The general principle: any system that cycles with period nn is governed by modular arithmetic. Months cycle with period 1212. Musical notes (in Western chromatic tuning) cycle with period 1212. Degree measurements on a compass cycle with period 360360. In each case, modulo captures the wrap-around — reducing an unbounded count to a position within a fixed cycle.
DownloadPNG2×PDF
Layout
Cyclic systemCycle period (modulus)Example
12-hour clock1215:00 on a 24-hour clock → 15 mod 12 = 3 → 3 o'clock
24-hour clock24hour 27 from midnight → 27 mod 24 = 3 → 3:00 AM
Days of the week7starting Sunday (0), day 10 of a sequence → 10 mod 7 = 3 → Wednesday
Months of the year1214 months from January (0) → 14 mod 12 = 2 → March
Chromatic musical notes12each octave repeats the 12-tone pattern; transposing by 12 semitones returns to the same note
Compass bearings (degrees)360a bearing of 720° → 720 mod 360 = 0° → due north (two full turns)
The Clock AnalogyLearn Math Class

Why Modulo Matters

At its simplest, modulo tests divisibility — check whether the remainder is zero. But the operation reaches far beyond that single question.

Pattern recognition depends on modulo. The last digit of any number is that number  mod 10\bmod 10. The last two digits are the number  mod 100\bmod 100. Identifying whether a number is even or odd is a  mod 2\bmod 2 test. These are modular observations embedded so deeply in everyday arithmetic that they rarely get named as such.

Many divisibility rules are modular arguments in compact form. The rule that a number is divisible by 99 if its digit sum is divisible by 99 rests on the fact that 10≡1(mod9)10 \equiv 1 \pmod{9}. The rule for 1111 uses 10≡−1(mod11)10 \equiv -1 \pmod{11}. Modulo provides the machinery; the rules are shortcuts derived from it.

In computer science, modulo controls array indexing, hash functions, and cyclic data structures. In cryptography, modular arithmetic underpins the algorithms that secure digital communication. The humble remainder, extracted from a simple division, turns out to be one of the most widely used tools in all of mathematics.

Formula Summary

This summary collects the formulas of the page in nine rows. Each row names a formula with a line on what it says and a link to its section, states it, and gives a short example from the page.

The first five rows are about the operation: the division equation that defines the remainder, the link to exact divisibility, the range the remainder stays in, the formula that computes it with the floor, and the edge cases of a small dividend and a divisor of one. The last four are about congruence: its meaning, the test through the difference, and the three properties that make it behave like equality.
DownloadPNG2×PDF
FormulaStatementExample
Division equationModulo returns the remainder rr of this equation, as what modulo is explains.a=n⋅q+r,0≤r<na = n \cdot q + r, \qquad 0 \leq r < n17=5⋅3+217 = 5 \cdot 3 + 2, so 17 mod 5=217 \bmod 5 = 2
Modulo and divisibilityA zero remainder means exact division, and a nonzero one says by how much the division misses (modulo and divisibility).a mod n=0a \bmod n = 0 exactly when n∣an \mid a24 mod 6=024 \bmod 6 = 0 and 6∣246 \mid 24
Range of remaindersExactly nn possible values, never nn itself, as the range of remainders shows.a mod na \bmod n is one of 0,1,2,…,n−10, 1, 2, \ldots, n - 1347 mod 10=7347 \bmod 10 = 7
Computing a remainderDivide, keep the integer part, multiply back and subtract, the steps of how to compute a remainder.a mod n=a−n⋅⌊an⌋\displaystyle a \bmod n = a - n \cdot \left\lfloor \frac{a}{n} \right\rfloor47 mod 5=47−5⋅9=247 \bmod 5 = 47 - 5 \cdot 9 = 2
Edge casesA number already below nn needs no reduction, while a mod 0a \bmod 0 is undefined, as the edge cases explain.a mod n=aa \bmod n = a for 0≤a<n0 \leq a < n, and a mod 1=0a \bmod 1 = 03 mod 10=33 \bmod 10 = 3
CongruenceTwo numbers with the same remainder; congruence is a statement about them, not an operation.a≡b(modn)a \equiv b \pmod{n} means a mod n=b mod na \bmod n = b \bmod n17≡5(mod12)17 \equiv 5 \pmod{12}
Difference testAn equivalent way to test a congruence through the difference, also from congruence.a≡b(modn)a \equiv b \pmod{n} exactly when n∣(a−b)n \mid (a - b)23−2=2123 - 2 = 21 and 7∣217 \mid 21, so 23≡2(mod7)23 \equiv 2 \pmod{7}
Reflexive and symmetricCongruence behaves like equality: a−a=0a - a = 0 is divisible by nn, and so is b−ab - a when a−ba - b is, as the properties of congruence show.a≡aa \equiv a, and a≡ba \equiv b gives b≡a(modn)b \equiv a \pmod{n}17≡517 \equiv 5 and 5≡17(mod12)5 \equiv 17 \pmod{12}
TransitiveWith the other two properties it splits the integers into congruence classes, as the properties of congruence explain.a≡ba \equiv b and b≡cb \equiv c give a≡c(modn)a \equiv c \pmod{n}modulo 33: three classes, with remainders 00, 11 and 22
Modulo formulasLearn Math Class
Keep the operation and the relation apart: a mod n is one number between zero and n minus one, while a congruence is a statement that is true or false. The remainder formula computes the first, and the difference test checks the second.

Common Pitfalls

Four mistakes account for many wrong remainders. Each is marked where it happens in the sections above; here each is worked through in full, with the wrong and the right working side by side.
DownloadPNG2×PDF
1Reading the decimal part as the remainder
A calculator divides 4747 by 55 and shows 9.49.4. The digits after the decimal point are read off as the remainder, as if 9.49.4 meant "99 remainder 44".
Wrong turn
Error here
47÷5=9.447 \div 5 = 9.4, so 47 mod 5=447 \bmod 5 = 4.
Right path
Keep the integer part 99, multiply back, 9×5=459 \times 5 = 45, and subtract, 47−45=247 - 45 = 2. So 47 mod 5=247 \bmod 5 = 2, and indeed 47=5⋅9+247 = 5 \cdot 9 + 2.
Why it happens"99 remainder 44" and 9.49.4 look alike, and the decimal point is read as a separator between quotient and remainder. The decimal part is a fraction of the divisor: 0.40.4 of 55 is 22.
How to checkPut the answer into the division equation. 5⋅9+4=495 \cdot 9 + 4 = 49, not 4747, so 44 cannot be the remainder; 5⋅9+2=475 \cdot 9 + 2 = 47 confirms 22.
2Giving the quotient instead of the remainder
When the dividend is smaller than the divisor, the divisor fits zero times, and that 00 is given as the answer. The 00 is the quotient; modulo asks for the remainder.
Wrong turn
Error here
1010 goes into 33 zero times, so 3 mod 10=03 \bmod 10 = 0.
Right path
3=10⋅0+33 = 10 \cdot 0 + 3 with 0≤3<100 \leq 3 < 10, so the quotient is 00 and the remainder is 33. So 3 mod 10=33 \bmod 10 = 3.
Why it happensThe first number found in a division is how many times the divisor fits, and "zero times" feels like the end of the work.
How to checkA remainder of 00 means that nn divides aa. Since 10∤310 \nmid 3, the answer cannot be 00. More generally, if 0≤a<n0 \leq a < n, then a mod n=aa \bmod n = a.
3Confusing mod with congruence
Any number congruent to aa modulo nn is given as the value of a mod na \bmod n. The congruence a≡b(modn)a \equiv b \pmod{n} holds for many values of bb, but the operation a mod na \bmod n returns exactly one number.
Wrong turn
Error here
17−7=1017 - 7 = 10 is divisible by 55, so 17≡7(mod5)17 \equiv 7 \pmod{5}, and therefore 17 mod 5=717 \bmod 5 = 7.
Right path
17=5⋅3+217 = 5 \cdot 3 + 2 with 0≤2<50 \leq 2 < 5, so 17 mod 5=217 \bmod 5 = 2. The congruence 17≡7(mod5)17 \equiv 7 \pmod{5} is also true, because 7 mod 5=27 \bmod 5 = 2 as well: both numbers land on the remainder 22.
Why it happensBoth use the word "mod", and 17≡7(mod5)17 \equiv 7 \pmod{5} read aloud sounds almost like "1717 mod 55 is 77".
How to checkThe value of a mod na \bmod n must lie in {0,1,…,n−1}\{0, 1, \ldots, n-1\}. For n=5n = 5 that set is {0,1,2,3,4}\{0, 1, 2, 3, 4\}, and 77 is not in it.
4Writing the modulus instead of 0
A clock face has 1212 at the top, so a count that lands exactly on the top of the dial is given as 1212. In modulo arithmetic that position is the remainder 00.
Wrong turn
Error here
At hour 2424 the hour hand points at 1212, so 24 mod 12=1224 \bmod 12 = 12.
Right path
24=12⋅2+024 = 12 \cdot 2 + 0, so 24 mod 12=024 \bmod 12 = 0. The remainder set for n=12n = 12 is {0,1,…,11}\{0, 1, \ldots, 11\}, and the dial's 1212 stands in for 00.
Why it happensEveryday clocks never show 00, and the label on the dial is taken as the remainder.
How to checkA remainder is always less than the modulus. An answer equal to nn means one more complete copy of nn can still be taken away.
Common pitfalls with remainders·/arithmetic/moduloLearn Math Class
Each slip reads the remainder from the wrong place. It is what is left after the largest multiple of nn is taken away: not the decimal digits of the quotient, not the quotient, and never nn or more, so a mod na \bmod n always lies in {0,1,…,n−1}\{0, 1, \ldots, n-1\}. Putting the answer back into a=nq+ra = nq + r catches each slip.

Section Roadmap

The pages that follow develop modulo in two directions.

Modular Arithmetic builds a self-contained system where addition, subtraction, multiplication, and exponentiation all operate within the confines of a fixed modulus. These tools solve problems involving last digits, cyclic patterns, and large powers that would be impractical to compute outright.

Negative Numbers addresses the convention split that arises when the dividend is negative — two valid definitions, different answers, and different behavior across programming languages.

Related Sections

Modulo connects to several areas of arithmetic that approach the same ideas from different angles.

Divisibility is the concept that modulo tests. The statement a mod n=0a \bmod n = 0 is the computational form of n∣an \mid a. Every divisibility question is, at its core, a modulo question.

Divisibility rules are modular arguments packaged as mental shortcuts. The digit-sum test for 99, the last-digit test for 55, the alternating-sum test for 1111 — each one exploits a congruence property of 1010 raised to successive powers.

The GCD — greatest common divisor — relies on modulo through the Euclidean algorithm, which repeatedly applies the modulo operation to reduce a pair of numbers until the remainder reaches zero. The last nonzero remainder is the GCD.

Summary: A Map of the Modulo Subtree

This page has surveyed modulo from definition through congruence to its role across arithmetic. The remaining detail — the full operation laws for modular addition, multiplication, and exponentiation, and the convention split that governs negative dividends — lives on dedicated child pages. The table below collects those pages plus the closely linked siblings in /arithmetic/divisibility, with a one-line indication of what each covers.
DownloadPNG2×PDF
Layout
TopicWhat you'll find therePage
Modular arithmetic operationsaddition, subtraction, multiplication, and exponentiation performed entirely within a fixed modulus — including last-digit problems and large-power computations/modulo/operations
Negative numbers in modulothe two conventions for handling negative dividends, the rounding choices that distinguish them, and how programming languages differ/modulo/negative-numbers
Divisibilitythe concept that modulo computes — the statement a mod n = 0 is the operational form of n ∣ a/arithmetic/divisibility
Divisibility rulesdigit-based shortcuts derived from how 10 behaves under modular arithmetic — each rule is a modular identity in compact form/divisibility/rules
GCD & Euclidean algorithmthe algorithm finds gcd(a, b) by repeatedly applying the modulo operation until the remainder reaches zero/divisibility/gcd
Summary: A Map of the Modulo SubtreeLearn Math Class

Skills You Should Learn

Each skill opens its step-by-step method page.
Arithmetic methods
  • Do modular arithmeticFind the remainder of a sum, product or power: reduce each number mod nn first, operate on the remainders, reduce again; use cycles for powers.
  • Find the GCD with the Euclidean algorithmReplace the pair (a,b)(a, b) by (b,a mod b)(b, a \bmod b) until the remainder is 00; the last nonzero remainder is the GCD. No factoring needed.
  • Find the modulo of a negative numberRound the quotient down, not toward zero, so the remainder lands in 0,…,n−10, \ldots, n - 1: (−38) mod 7=4(-38) \bmod 7 = 4 because −38=7⋅(−6)+4-38 = 7 \cdot (-6) + 4.

Modulo FAQ

What is the difference between mod and % operators?

+
Mathematical notation writes a mod n; most programming languages write a % n. For positive integers the two agree completely. For negative operands they can disagree: -7 % 3 gives 2 in Python but -1 in C and JavaScript, because languages differ over whether the result follows the divisor's sign. The details are covered in modulo with negative numbers.Read more →

How do you test if a number is even or odd using modulo?

+
A number is even if n mod 2 = 0, and odd if n mod 2 = 1 — evenness is exact divisibility by 2, so the remainder decides. Similarly, for a non-negative number n mod 10 gives the last digit, and n mod 100 gives the last two digits.Read more →

What is a congruence class?

+
A congruence class (also called a residue class) modulo n is the set of all integers sharing the same remainder when divided by n. For n = 3, the integers partition into three classes: multiples of 3 (remainder 0), those with remainder 1, and those with remainder 2. Every integer belongs to exactly one class.Read more →

What is the difference between a mod n and a ≡ b (mod n)?

+
a mod n is an operation that produces a number: the remainder. a ≡ b (mod n) is a relationship stating that a and b leave the same remainder when divided by n. The first computes a value, the second asserts a fact — 17 mod 5 = 2 is a computation, while 17 ≡ 2 (mod 5) is a true statement about two numbers.Read more →

What is a number mod 0?

+
It is undefined. Division by zero has no meaning, and the division equation cannot pin down a remainder either: a=0⋅q+aa = 0 \cdot q + a holds for every qq, so the quotient is not unique, and no remainder can satisfy 0≤r<00 \leq r < 0. In code, Python and Java stop with an error, and JavaScript returns NaN. The smallest allowed modulus is 11, and a mod 1=0a \bmod 1 = 0 for every integer aa.Read more →

Why do some ISBNs end in X?

+
Because the check character can need the value 1010. A 10-digit ISBN is valid when 10d1+9d2+…+1⋅d1010d_1 + 9d_2 + \ldots + 1 \cdot d_{10} is divisible by 1111, so the last character is whichever value from 00 to 1010 makes that happen. A single digit place holds only 00 to 99, so 1010 is written X. Because 1111 is prime, any single wrong digit, and any swap of two different digits, breaks the check.Read more →

Is 24 mod 12 equal to 12 or 0?

+
It is 00. Since 24=12⋅2+024 = 12 \cdot 2 + 0, nothing is left after two full turns, and a remainder modulo 1212 must lie in {0,1,…,11}\{0, 1, \ldots, 11\}, so 1212 is never a possible answer. The dial shows 12 at that position only because everyday clocks have no 0; in modulo arithmetic the top of the dial is the remainder 00, and 36 mod 12=036 \bmod 12 = 0 as well.Read more →

Does the 13th of the month fall on a Friday more often than on other days?

+
Yes, slightly. The Gregorian calendar repeats every 400400 years: 146,097146{,}097 days, exactly 20,87120{,}871 weeks, so the weekday pattern comes back unchanged forever. The cycle holds 48004800 thirteenths, which is not a multiple of 77, so the weekdays cannot share them equally. The count is Friday 688688, Sunday and Wednesday 687687, Monday and Tuesday 685685, Thursday and Saturday 684684.Read more →