Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Modulo Operations






Arithmetic That Wraps Around

Computing a remainder answers a single question about a single number. Modular arithmetic goes further — it builds a complete system where addition, subtraction, multiplication, and exponentiation all operate within the confines of a fixed modulus. Numbers exceeding the range cycle back, and the arithmetic never leaves the set {0,1,2,…,n−1}\{0, 1, 2, \ldots, n-1\}.

Key Terms

Congruence— the equivalence relation that makes modular operations valid
Modulus— the fixed divisor defining the arithmetic system
Remainder— every operation reduces results back to the remainder set
Residue Class— modular arithmetic operates on classes, not individual integers

See All Arithmetic Definitions →


Operating Within a Modulus

Ordinary arithmetic runs along an endless number line: 9 + 7 = 16, and results can grow without limit.
A clock does not work that way. Its hand wraps round after 1212, so 55 hours after 1010 o'clock it is 33 o'clock, not 1515.
Keeping only the remainder after dividing by n turns each answer into one of n slots.
operationordinary answermod 10mod 12 (a clock)
9 + 71664
10 + 51553
7 · 85668
3 − 8−557
Each entry in the last two columns is the remainder of the ordinary answer: 16=10+616 = 10 + 6, 56=12⋅4+856 = 12 \cdot 4 + 8, and −5=10⋅(−1)+5-5 = 10 \cdot (-1) + 5.
The definition
Modular arithmetic with modulus nn works only with the remainders 0,1,…,n−10, 1, \dots, n - 1: every sum, difference and product is replaced by its remainder on division by nn.
Standard arithmetic works on the full number line — results can grow without bound. Modular arithmetic restricts the playing field. Every number is reduced to one of nn possible remainders, and every operation stays within that set.
So 9+7≡6(mod10)9 + 7 \equiv 6 \pmod{10} and 7⋅8≡6(mod10)7 \cdot 8 \equiv 6 \pmod{10}, while on a 1212-hour clock 10+5≡310 + 5 \equiv 3.
It is an arithmetic of its own, on a finite set of numbers.
Add 9+79 + 7 in ordinary arithmetic and the answer is 1616. Add 9+79 + 7 modulo 1010 and the answer is 66 — the sum wraps past 99 and cycles back. The number 1616 and the number 66 are different on the number line, but they are the same in the world of  mod 10\bmod 10.
The mental model is a clock with nn hours. On a 1010-hour clock, moving 77 steps forward from 99 lands on 66, not 1616. On a 1212-hour clock, 10+5=310 + 5 = 3, not 1515. The numbers wrap around whenever they reach the modulus.
This wrap-around is not an approximation or a shortcut — it is a self-contained arithmetic system with its own rules, and those rules are precise enough to produce exact answers to problems that would be impractical to solve on the full number line.
★ 012345mod 6
The playing field mod 6: slots 0 to 5

Every number, however large, is reduced to one of the six slots on the wheel, and every operation is carried out slot by slot: adding 4 to a number moves its slot four places round, and the result never leaves the wheel. That is the finite arithmetic this page builds. Watch sums and products stay on the wheel on the modular arithmetic wheel.

The core principle in the next section is why reducing early and reducing late give the same slot.
Nothing is lost for addition, subtraction and multiplication: reducing early gives the same answer as reducing at the end.
For 89⋅76 mod 989 \cdot 76 \bmod 9, replacing 8989 by 88 and 7676 by 44 gives 3232, which leaves 55; the full product 6,7646{,}764 leaves 55 too. Why this always works is set out in the core principle.
What is lost: division does not carry over so simply.
Modulo 1010, 2⋅5≡02 \cdot 5 \equiv 0 although neither factor is 00, so dividing by 22 cannot always be undone. The details are in why division is different.
The rest of the page covers the core principle, addition, subtraction, multiplication and powers, cycles in powers, division, and last-digit, clock and day-of-week problems.

The Core Principle

The power of modular arithmetic comes from one fact: reducing numbers before, during, or after an operation all produce the same final remainder.

This means large numbers can be replaced by their remainders at any stage of a calculation without affecting the outcome. The formal statement, in the congruence notation of the parent page: if a≡a′(modn)a \equiv a' \pmod{n} and b≡b′(modn)b \equiv b' \pmod{n}, then:

The Core Principle
a+b≡a′+b′(modn)a + b \equiv a' + b' \pmod{n}

The Core Principle
a−b≡a′−b′(modn)a - b \equiv a' - b' \pmod{n}

The Core Principle
a⋅b≡a′⋅b′(modn)a \cdot b \equiv a' \cdot b' \pmod{n}

In words: replacing any number with a congruent one does not change the remainder of the result. The product 89×7689 \times 76 modulo 99 does not require computing 6,7646{,}764 first — replacing 8989 with 88 and 7676 with 44 gives 3232, and 32 mod 9=532 \bmod 9 = 5. The answer is the same either way.

This principle is what makes modular arithmetic practical. Without it, every computation would require handling the full-size numbers and reducing only at the end.

Addition

Modular addition reduces each operand, adds the results, and reduces once more if the sum reaches or exceeds nn:

Addition
(a+b) mod n=((a mod n)+(b mod n)) mod n(a + b) \bmod n = ((a \bmod n) + (b \bmod n)) \bmod n

Example
For (47+38) mod 10(47 + 38) \bmod 10: reduce 4747 to 77 and 3838 to 88. Add: 7+8=157 + 8 = 15. Reduce: 15 mod 10=515 \bmod 10 = 5.

Example
For (123+456) mod 7(123 + 456) \bmod 7: reduce 123123 to 44 and 456456 to 11. Add: 4+1=54 + 1 = 5. Since 5<75 < 7, no further reduction is needed.

The final reduction is necessary because the sum of two remainders can reach as high as 2(n−1)2(n - 1). For  mod 10\bmod 10, the largest possible intermediate sum is 9+9=189 + 9 = 18, which still needs one more reduction. But it can never reach 2n2n, so a single reduction always suffices.
The first example of this section, one step at a time. Press Next to carry out each step.
DownloadPNG2×PDF
(47+38) mod 10(47 + 38) \bmod 10Step 1 of 3
Step
(47+38) mod 10(47 + 38) \bmod 10
1
Reduce each operand
47→747 \to 7 and 38→838 \to 8
2
Add the results
7+8=157 + 8 = 15
3
Reduce once more if the sum reaches or exceeds nn
15 mod 10=515 \bmod 10 = 5
Reduce, add, reduceLearn Math Class

Subtraction

Modular subtraction follows the same reduce-operate-reduce pattern, with one wrinkle: the intermediate result may be negative.

Subtraction
(a−b) mod n=((a mod n)−(b mod n)) mod n(a - b) \bmod n = ((a \bmod n) - (b \bmod n)) \bmod n

Example
For (23−47) mod 10(23 - 47) \bmod 10: reduce 2323 to 33 and 4747 to 77. Subtract: 3−7=−43 - 7 = -4. The result is negative, so add nn: −4+10=6-4 + 10 = 6.
The alternative is to compute the full subtraction first: 23−47=−2423 - 47 = -24, then −24 mod 10=6-24 \bmod 10 = 6 (using the floored convention). Either route gives 66.

Pitfall: Ignoring the minus sign
Reducing −24-24 as if it were 2424 gives −24 mod 10=4-24 \bmod 10 = 4, yet −24−4=−28-24 - 4 = -28 is not a multiple of 1010. Going down to −30-30 gives −24=10⋅(−3)+6-24 = 10 \cdot (-3) + 6, so the result is 66.

The negative intermediate result is not an error — it reflects a position on the number cycle that has wrapped past zero in the backward direction. Adding nn translates it to its equivalent position in {0,1,…,n−1}\{0, 1, \ldots, n-1\}.
The example of this section, one step at a time. Press Next to carry out each step.
DownloadPNG2×PDF
(23−47) mod 10(23 - 47) \bmod 10Step 1 of 3
Step
(23−47) mod 10(23 - 47) \bmod 10
1
Reduce each operand
23→323 \to 3 and 47→747 \to 7
2
Subtract the results
3−7=−43 - 7 = -4
3
If the result is negative, add nn
−4+10=6-4 + 10 = 6
Reduce, subtract, add nLearn Math Class

Multiplication

Modular multiplication reduces each factor, multiplies the remainders, and reduces the product:

Multiplication
(a⋅b) mod n=((a mod n)⋅(b mod n)) mod n(a \cdot b) \bmod n = ((a \bmod n) \cdot (b \bmod n)) \bmod n

Example
For (23⋅17) mod 5(23 \cdot 17) \bmod 5: reduce 2323 to 33 and 1717 to 22. Multiply: 3⋅2=63 \cdot 2 = 6. Reduce: 6 mod 5=16 \bmod 5 = 1.

Example
For (89⋅76) mod 9(89 \cdot 76) \bmod 9: reduce 8989 to 88 and 7676 to 44. Multiply: 8⋅4=328 \cdot 4 = 32. Reduce: 32 mod 9=532 \bmod 9 = 5.

The savings are dramatic for large numbers. The product 89×76=6,76489 \times 76 = 6{,}764 is never needed — the same answer emerges from the product 8×4=328 \times 4 = 32, a computation simple enough to do mentally.

The principle chains through multiple factors. For (13⋅17⋅19) mod 5(13 \cdot 17 \cdot 19) \bmod 5: reduce to 3⋅2⋅4=243 \cdot 2 \cdot 4 = 24, then 24 mod 5=424 \bmod 5 = 4. Reduce at every step to keep the numbers small.
The second example of this section, one step at a time. Press Next to carry out each step.
DownloadPNG2×PDF
(89⋅76) mod 9(89 \cdot 76) \bmod 9Step 1 of 3
Step
(89⋅76) mod 9(89 \cdot 76) \bmod 9
1
Reduce each factor
89→889 \to 8 and 76→476 \to 4
2
Multiply the remainders
8⋅4=328 \cdot 4 = 32
3
Reduce the product
32 mod 9=532 \bmod 9 = 5
Reduce, multiply, reduceLearn Math Class

Powers

Computing ak mod na^k \bmod n by first calculating aka^k and then reducing is impractical — the intermediate number grows exponentially. Instead, reduce after every multiplication.

Example
For 74 mod 107^4 \bmod 10, build the power step by step:
71 mod 10=77^1 \bmod 10 = 7
72=7⋅7=49→49 mod 10=97^2 = 7 \cdot 7 = 49 \to 49 \bmod 10 = 9
73=9⋅7=63→63 mod 10=37^3 = 9 \cdot 7 = 63 \to 63 \bmod 10 = 3
74=3⋅7=21→21 mod 10=17^4 = 3 \cdot 7 = 21 \to 21 \bmod 10 = 1
The answer is 11.

The largest intermediate number was 6363 — far smaller than 74=2,4017^4 = 2{,}401.

Fact: Exponents with 600 digits
RSA encryption computes cd mod nc^d \bmod n with an exponent dd of about 600600 digits. Squaring and reducing gets there in fewer than 4,1004{,}100 multiplications, while cdc^d written out in full would have more digits than there are atoms in the universe.

The same power can be reached faster by squaring. Squaring 77 gives 72=49→97^2 = 49 \to 9, and squaring again gives 74=92=81→17^4 = 9^2 = 81 \to 1: two multiplications instead of three. Each squaring doubles the exponent, so a1024a^{1024} takes only ten squarings, and any other power is a product of these squares, chosen by the binary digits of the exponent.

Example
For 310 mod 73^{10} \bmod 7:
31=33^1 = 3, 32=9→23^2 = 9 \to 2, 33=63^3 = 6, 34=18→43^4 = 18 \to 4, 35=12→53^5 = 12 \to 5, 36=15→13^6 = 15 \to 1.
At 363^6, the remainder returns to 11. From here: 310=36⋅34≡1⋅4=4(mod7)3^{10} = 3^6 \cdot 3^4 \equiv 1 \cdot 4 = 4 \pmod{7}.
The first example of this section, one multiplication at a time. Press Next to carry out each step.
DownloadPNG2×PDF
74 mod 107^4 \bmod 10Step 1 of 11
Values now
exponent =11product =–remainder =77
This step
71 mod 10=77^1 \bmod 10 = 7.
Power modulo nn
1Start with a mod na \bmod n
2Multiply the current remainder by aa
3Reduce the product modulo nn
4Repeat until the exponent reaches kk
5The last remainder is ak mod na^k \bmod n
One row per multiplication
PowerMultiplyRemainder
1727^27⋅7=497 \cdot 7 = 4999
2737^39⋅7=639 \cdot 7 = 6333
3747^43⋅7=213 \cdot 7 = 2111
Result
Reducing after every multiplicationLearn Math Class

Detecting Cycles in Powers

THEOREM
Because  mod n\bmod n confines remainders to a finite set, the sequence of remainders a1,a2,a3,… mod na^1, a^2, a^3, \ldots \bmod n must eventually repeat.

Once a remainder reappears, the entire pattern cycles from that point forward.

Powers of 2 mod 72 \bmod 7 produce the sequence: 2,4,1,2,4,1,2,4,1,…2, 4, 1, 2, 4, 1, 2, 4, 1, \ldots The cycle {2,4,1}\{2, 4, 1\} has length 33 and repeats indefinitely.

Example
To compute 2100 mod 72^{100} \bmod 7, divide the exponent by the cycle length: 100=3⋅33+1100 = 3 \cdot 33 + 1. The remainder is 11, so 21002^{100} lands at the same position as 212^1 in the cycle. The answer is 22.

Pitfall: Reducing the exponent by the modulus
Reducing the exponent of 21002^{100} modulo 77 gives 100 mod 7=2100 \bmod 7 = 2 and 22=42^2 = 4. The powers repeat every 33 steps, not every 77: 100 mod 3=1100 \bmod 3 = 1, so 2100 mod 7=22^{100} \bmod 7 = 2.

Example
Powers of 3 mod 103 \bmod 10 cycle through {3,9,7,1}\{3, 9, 7, 1\} with length 44. For 375 mod 103^{75} \bmod 10: 75=4⋅18+375 = 4 \cdot 18 + 3, so 3753^{75} matches 33=73^3 = 7. The answer is 77.

The cycle always closes once the remainder 11 appears (assuming it does), because ak≡1a^k \equiv 1 implies ak+j≡aja^{k+j} \equiv a^j for any jj — the sequence restarts.
DownloadPNG2×PDF
Layout
Base aModulus nCycle of aᵏ mod n (k = 1, 2, 3, …)Period
27{2, 4, 1}3
37{3, 2, 6, 4, 5, 1}6
25{2, 4, 3, 1}4
35{3, 4, 2, 1}4
Detecting Cycles in PowersLearn Math Class
Powers of 2 mod 7 for k = 1 to 9: 2, 4, 1 repeating with cycle length 3k2ᵏ mod 7123456789101234562, 4, 1, 2, 4, 1, 2, 4, 1, …amber: each new cycle starts2¹⁰⁰: 100 = 3 · 33 + 1, so 2Finitely many remainders force the powers to cycle
The powers of 2 modulo 7 repeat

Each dot is 2ᵏ mod 7 for k = 1 to 9. The values run 2, 4, 1 and then start over, because 2³ = 8 ≡ 1 (mod 7) and multiplying by 2 again returns to 2. The amber dots mark where each new cycle begins, at k = 1, 4, 7. Any exponent can be reduced by the cycle length 3: 100 = 3 · 33 + 1, so 2¹⁰⁰ mod 7 equals 2¹ mod 7 = 2.

A power of 2 is never a multiple of 7, so only 6 remainders are possible, and a repeat must come within the first 7 powers.
Powers modulo nn always fall into a cycle, so even a huge exponent matters only through its place in that cycle.

Why Division Is Different

Addition, subtraction, and multiplication all pass through  mod n\bmod n cleanly. Division does not.

Consider 12÷4=312 \div 4 = 3. Working modulo 55: 12 mod 5=212 \bmod 5 = 2 and 4 mod 5=44 \bmod 5 = 4. Dividing the remainders gives 24=0.5\frac{2}{4} = 0.5 — not an integer, and certainly not 3 mod 5=33 \bmod 5 = 3.

The problem is that division undoes multiplication, but modular reduction discards information that division needs to recover. The product 4⋅3=124 \cdot 3 = 12 reduces to 2 mod 52 \bmod 5, and knowing only 22 and 44 is not enough to reconstruct 33 through ordinary division.

Modular division requires a different tool: the modular inverse. The inverse of bb modulo nn is a number b−1b^{-1} such that b⋅b−1≡1(modn)b \cdot b^{-1} \equiv 1 \pmod{n}. Dividing by bb then means multiplying by b−1b^{-1}. Not every number has an inverse for every modulus — the theory belongs to number theory and is not covered here.
Remainders can be added, subtracted and multiplied freely, but never divided directly: dividing by bb means multiplying by an inverse of bb.

Last Digit Problems

RULE
The last digit of any number is that number  mod 10\bmod 10.

Finding the last digit of a large power reduces to modular exponentiation with n=10n = 10.

Example
Find the last digit of 71007^{100}. The powers of 7 mod 107 \bmod 10 cycle: 7,9,3,1,7,9,3,1,…7, 9, 3, 1, 7, 9, 3, 1, \ldots with period 44.
Divide the exponent by the cycle length: 100=4⋅25+0100 = 4 \cdot 25 + 0. A remainder of 00 means the exponent aligns with the end of a full cycle — the position of 747^4, whose last digit is 11.

Pitfall: Reading remainder 0 as the first place
Reading the remainder 00 in 20=4⋅5+020 = 4 \cdot 5 + 0 as the first place of the cycle 2,4,8,62, 4, 8, 6 gives 22 as the last digit of 2202^{20}. A remainder of 00 points to the last place, so the last digit is 66.

Example
Find the last digit of 3753^{75}. The powers of 3 mod 103 \bmod 10 cycle: 3,9,7,13, 9, 7, 1 with period 44. Divide: 75=4⋅18+375 = 4 \cdot 18 + 3. The remainder 33 points to the third position in the cycle: 77.

The method works for any base. Identify the cycle of last digits, find the exponent's position within that cycle, and read off the answer — no need to compute the full power.
DownloadPNG2×PDF
Layout
Base last digit dCycle of dᵏ mod 10 (k = 1, 2, 3, …)Period
0{0}1
1{1}1
2{2, 4, 8, 6}4
3{3, 9, 7, 1}4
4{4, 6}2
5{5}1
6{6}1
7{7, 9, 3, 1}4
8{8, 4, 2, 6}4
9{9, 1}2
Last Digit ProblemsLearn Math Class

Clock Problems

Time wraps around, making clock questions natural applications of modular arithmetic.

A 1212-hour clock operates  mod 12\bmod 12. If it is 10:0010{:}00 now, what time will it be in 5050 hours? Compute (10+50) mod 12=60 mod 12=0(10 + 50) \bmod 12 = 60 \bmod 12 = 0. On a 1212-hour clock, a remainder of 00 corresponds to 12:0012{:}00.

A 2424-hour clock operates  mod 24\bmod 24. If it is 21:0021{:}00 (9 PM), what time will it be in 100100 hours? Compute (21+100) mod 24=121 mod 24(21 + 100) \bmod 24 = 121 \bmod 24. Divide: 121=24⋅5+1121 = 24 \cdot 5 + 1. The answer is 1:001{:}00 — one o'clock in the morning.

The same logic handles backward calculations. If it is 3:003{:}00 now, what time was it 2020 hours ago? Compute (3−20) mod 12=−17 mod 12(3 - 20) \bmod 12 = -17 \bmod 12. Adding 2424 (two full cycles): −17+24=7-17 + 24 = 7. It was 7:007{:}00.

Day of Week Problems

Days of the week cycle with period 77, making them a  mod 7\bmod 7 system. Assign numbers: Sunday =0= 0, Monday =1= 1, Tuesday =2= 2, Wednesday =3= 3, Thursday =4= 4, Friday =5= 5, Saturday =6= 6.

Example
Today is Wednesday (day 33). What day is it in 100100 days? Compute (3+100) mod 7=103 mod 7(3 + 100) \bmod 7 = 103 \bmod 7. Divide: 103=7⋅14+5103 = 7 \cdot 14 + 5. Day 55 is Friday.

Example
January 11 is a Monday (day 11). What day is March 1515? Count the days: 3131 (remaining in January) +28+ 28 (February) +14+ 14 (first 1414 days of March) =73= 73 days later. Compute (1+73) mod 7=74 mod 7(1 + 73) \bmod 7 = 74 \bmod 7. Divide: 74=7⋅10+474 = 7 \cdot 10 + 4. Day 44 is Thursday.

Pitfall: Counting the days off by one
Counting 31−1=3031 - 1 = 30 days for the rest of January gives 7272 days and (1+72) mod 7=3(1 + 72) \bmod 7 = 3, a Wednesday. January 1 to February 1 is 3131 days, so the count is 7373 and March 15 is a Thursday.

In date problems the reduction modulo 77 is the easy step; the work lies in the day count. The number added to the starting day is the number of days that pass between the two dates, and it is built from the month lengths before any reduction is done.

Larger spans work identically.

Example
What day is it 1,0001{,}000 days from a Tuesday (day 22)? Compute (2+1000) mod 7=1002 mod 7(2 + 1000) \bmod 7 = 1002 \bmod 7. Divide: 1002=7⋅143+11002 = 7 \cdot 143 + 1. Day 11 is Monday.

Why Divisibility Rules Work

The familiar divisibility rules are modular arithmetic in disguise. Each rule exploits a congruence property of 1010 — the base of our number system.

Fact: One test for 7, 11 and 13
Because 1001=7⋅11⋅131001 = 7 \cdot 11 \cdot 13, 1000≡−11000 \equiv -1 modulo all three, so the alternating sum of three-digit blocks tests 77, 1111 and 1313 at once. For 1,234,5671{,}234{,}567 it is 567−234+1=334567 - 234 + 1 = 334, which none of them divides, so neither does the number.

The digit-sum rule for 99 works because 10≡1(mod9)10 \equiv 1 \pmod{9}. Every power of 1010 is congruent to 11: 100=110^0 = 1, 101≡110^1 \equiv 1, 102≡110^2 \equiv 1, and so on. A digit dd in the kkth place contributes d⋅10k≡d⋅1=d(mod9)d \cdot 10^k \equiv d \cdot 1 = d \pmod{9}. The place value drops away, and only the digit itself matters. So the entire number is congruent to the sum of its digits modulo 99.
The argument for 99 as a chain of congruences, each with its reason.
DownloadPNG2×PDF
ProveA number is congruent to the sum of its digits modulo 99
1
10≡1(mod9)10 \equiv 1 \pmod{9}
baseThe fact the digit-sum rule for 99 rests on
2
100=110^0 = 1, 101≡110^1 \equiv 1, 102≡110^2 \equiv 1, and so on
powersEvery power of 1010 is congruent to 11
3
d⋅10k≡d⋅1d \cdot 10^k \equiv d \cdot 1
one digitA digit dd in the kkth place, with its place value
4
=d(mod9)= d \pmod{9}
key stepThe place value drops away, and only the digit itself matters
The entire number is congruent to the sum of its digits modulo 99
Why the digit-sum rule for 9 worksLearn Math Class
The last line is the decisive one: once every power of 1010 counts as 11, the place value of each digit drops away.
The rule for 33 follows identically: 10≡1(mod3)10 \equiv 1 \pmod{3}, so the digit sum also determines divisibility by 33.

The alternating-sum rule for 1111 works because 10≡−1(mod11)10 \equiv -1 \pmod{11}. Powers of 1010 alternate: 100=110^0 = 1, 101≡−110^1 \equiv -1, 102≡110^2 \equiv 1, 103≡−110^3 \equiv -1. Each digit's contribution alternates in sign depending on its position, producing the alternating sum.

Every shortcut in the divisibility rules page traces back to a congruence property of 1010 modulo the divisor in question. Modular arithmetic is the engine; the rules are the user-facing controls.

Worked Examples

Compute (137⋅249) mod 7(137 \cdot 249) \bmod 7. Reduce: 137 mod 7=4137 \bmod 7 = 4 and 249 mod 7=4249 \bmod 7 = 4. Multiply: 4⋅4=164 \cdot 4 = 16. Reduce: 16 mod 7=216 \bmod 7 = 2.

Find the last two digits of 7507^{50} (that is, 750 mod 1007^{50} \bmod 100). Compute powers step by step: 71=77^1 = 7, 72=497^2 = 49, 74=492=2401→1 mod 1007^4 = 49^2 = 2401 \to 1 \bmod 100. Since 74≡1(mod100)7^4 \equiv 1 \pmod{100}, and 50=4⋅12+250 = 4 \cdot 12 + 2, we get 750≡72=49(mod100)7^{50} \equiv 7^2 = 49 \pmod{100}. The last two digits are 4949.

A meeting happens every 88 days. Another happens every 1212 days. Both occur today. When do they next coincide? The answer is the LCM of 88 and 1212, which is 2424 — but modular thinking frames it as: find the smallest d>0d > 0 such that d≡0(mod8)d \equiv 0 \pmod{8} and d≡0(mod12)d \equiv 0 \pmod{12}.

Verify that 8,3618{,}361 is divisible by 99. Digit sum: 8+3+6+1=188 + 3 + 6 + 1 = 18, then 1+8=91 + 8 = 9. Since 9≡0(mod9)9 \equiv 0 \pmod 9, the number is divisible by 99. Confirm: 8361=9⋅9298361 = 9 \cdot 929.

Simplify (250+350) mod 5(2^{50} + 3^{50}) \bmod 5. Powers of 2 mod 52 \bmod 5 cycle {2,4,3,1}\{2, 4, 3, 1\} with period 44. Since 50=4⋅12+250 = 4 \cdot 12 + 2, 250≡4(mod5)2^{50} \equiv 4 \pmod{5}. Powers of 3 mod 53 \bmod 5 cycle {3,4,2,1}\{3, 4, 2, 1\} with period 44. Since 50=4⋅12+250 = 4 \cdot 12 + 2, 350≡4(mod5)3^{50} \equiv 4 \pmod{5}. Sum: 4+4=8→8 mod 5=34 + 4 = 8 \to 8 \bmod 5 = 3.

To check modular results with your own numbers, use the modulo calculator.

Summary: The Operations Toolkit

Every problem on this page, from combining remainders to last digits, clock positions, days of the week and divisibility rules, draws on the same five operations. This summary gives one row to each: the operation with its procedure and a link to its section, the compact formula, and a worked example.

Addition, subtraction and multiplication share one pattern: reduce the inputs, combine them, and reduce the result, with a negative difference moved back into range by adding the modulus. Powers are built one multiplication at a time and shortened by their cycle. Division gets a row of its own because it does not pass through the modulus and needs an inverse instead.
DownloadPNG2×PDF
OperationCompact formulaWorked example
AdditionReduce each operand, add, and reduce once more if the sum is nn or more, as addition shows.(a+b) mod n=((a mod n)+(b mod n)) mod n(a + b) \bmod n = ((a \bmod n) + (b \bmod n)) \bmod n(47+38) mod 10(47 + 38) \bmod 10: 7+8=15→15 mod 10=57 + 8 = 15 \to 15 \bmod 10 = 5
SubtractionReduce each operand and subtract; if the result is negative, add nn, as subtraction shows.(a−b) mod n=((a mod n)−(b mod n)) mod n(a - b) \bmod n = ((a \bmod n) - (b \bmod n)) \bmod n(23−47) mod 10(23 - 47) \bmod 10: 3−7=−4→−4+10=63 - 7 = -4 \to -4 + 10 = 6
MultiplicationReduce each factor, multiply, and reduce the product, as multiplication shows.(a⋅b) mod n=((a mod n)⋅(b mod n)) mod n(a \cdot b) \bmod n = ((a \bmod n) \cdot (b \bmod n)) \bmod n(89⋅76) mod 9(89 \cdot 76) \bmod 9: 8⋅4=32→32 mod 9=58 \cdot 4 = 32 \to 32 \bmod 9 = 5
ExponentiationBuild the power one multiplication at a time, reducing after each step, and detect the cycle once a remainder repeats, as powers shows.ak mod na^k \bmod n via repeated (⋅ a) mod n(\cdot \, a) \bmod n; for large kk, use the exponent mod the period74 mod 107^4 \bmod 10: 7→9→3→17 \to 9 \to 3 \to 1 (intermediates stay under 100100)
DivisionDivision does not pass through  mod n\bmod n directly, so it multiplies by the modular inverse instead, as why division is different explains.a/b≡a⋅b−1(modn)a / b \equiv a \cdot b^{-1} \pmod{n}, where b⋅b−1≡1(modn)b \cdot b^{-1} \equiv 1 \pmod{n}the inverse b−1b^{-1} may not exist; it depends on gcd⁡(b,n)\gcd(b, n), and the full treatment lies in number theory
Modular operationsLearn Math Class
Reduce early and reduce often: for sums, differences, products and powers this keeps every number small without changing the answer. Division is the one exception, so a quotient of remainders calls for an inverse, not for ordinary division.

Common Pitfalls

Five mistakes account for many of the wrong answers in modular arithmetic. Four are marked where they happen in the sections above; dividing the remainders is the one the division section already shows. Here each is worked through in full, with the wrong and the right working side by side.
DownloadPNG2×PDF
1Ignoring the minus sign
A negative number is reduced by its size alone, as if −24-24 and 2424 had the same remainder. The sign is dropped, or put back in front of the remainder of the positive number.
Wrong turn
Error here
24=10⋅2+424 = 10 \cdot 2 + 4, so −24 mod 10=4-24 \bmod 10 = 4.
Right path
The remainder rr must satisfy −24=10q+r-24 = 10q + r with 0≤r<100 \leq r < 10. The multiple of 1010 at or below −24-24 is −30-30, so −24=10⋅(−3)+6-24 = 10 \cdot (-3) + 6 and −24 mod 10=6-24 \bmod 10 = 6. The route through remainders agrees: 3−7=−43 - 7 = -4 and −4+10=6-4 + 10 = 6.
Why it happensFor positive numbers the remainder is what is left after taking away multiples of nn, and that habit is carried over to negative numbers, where the step goes down to the next multiple, away from zero.
How to checkThe number minus the result must be a multiple of nn. −24−6=−30-24 - 6 = -30 passes; −24−4=−28-24 - 4 = -28 fails.
2Reducing the exponent by the modulus
The base of a power may be replaced by its remainder, and the same move is made on the exponent: it is reduced modulo nn instead of modulo the length of the cycle of powers.
Start
For 2100 mod 72^{100} \bmod 7, 100=7⋅14+2100 = 7 \cdot 14 + 2,
Wrong turn
Error here
So 2100≡22=4(mod7)2^{100} \equiv 2^2 = 4 \pmod{7}.
Right path
The powers of 22 modulo 77 run 2,4,12, 4, 1 and repeat, so the cycle length is 33. Since 100=3⋅33+1100 = 3 \cdot 33 + 1, 2100≡21=2(mod7)2^{100} \equiv 2^1 = 2 \pmod{7}.
Why it happensThe core principle allows any number in a sum or a product to be replaced by its remainder, and the exponent looks like one more such number. But the exponent counts multiplications, and the count repeats with the cycle, not with nn.
How to checkTry a small exponent that can be worked out in full. 27=128=7⋅18+22^7 = 128 = 7 \cdot 18 + 2, so 27 mod 7=22^7 \bmod 7 = 2, while reducing the exponent 77 modulo 77 would give 20=12^0 = 1.
3Dividing the remainders
A quotient is reduced by reducing the dividend and the divisor first and then dividing, as is done for sums, differences and products.
Start
For (12÷4) mod 5(12 \div 4) \bmod 5, 12 mod 5=212 \bmod 5 = 2 and 4 mod 5=44 \bmod 5 = 4,
Wrong turn
Error here
So the answer is 24=0.5\frac{2}{4} = 0.5.
Right path
Divide before reducing, 12÷4=312 \div 4 = 3 and 3 mod 5=33 \bmod 5 = 3. Working only with remainders, dividing by 44 means multiplying by the inverse of 44: 4⋅4=16≡1(mod5)4 \cdot 4 = 16 \equiv 1 \pmod{5}, so the inverse is 44 and 2⋅4=8≡3(mod5)2 \cdot 4 = 8 \equiv 3 \pmod{5}.
Why it happensAddition, subtraction and multiplication all allow reducing first, so division is expected to work the same way.
How to checkMultiply back. The answer times the divisor must be congruent to the dividend: 3⋅4=12≡2(mod5)3 \cdot 4 = 12 \equiv 2 \pmod{5}. A result like 0.50.5 is not a remainder at all.
4Reading remainder 0 as the first place
In a last-digit problem the exponent is divided by the cycle length, and a remainder of 00 is matched with the first entry of the cycle, or with the power a0=1a^0 = 1.
Start
The last digits of the powers of 22 cycle 2,4,8,62, 4, 8, 6.
Wrong turn
Error here
For 2202^{20}, 20=4⋅5+020 = 4 \cdot 5 + 0, and the remainder 00 is read as the first place, giving 22.
Right path
A remainder of 00 means the exponent is a whole number of cycles, so 2202^{20} sits in the same place as 24=162^4 = 16, the last place of the cycle. The last digit is 66, and indeed 220=1,048,5762^{20} = 1{,}048{,}576.
Why it happensThe remainders 11, 22 and 33 match the first, second and third places directly, and 00 matches no place number, so it is attached to the start.
How to checkReplace a remainder of 00 by the cycle length. The exponent 2020 then behaves like the exponent 44, and 24=162^4 = 16 ends in 66.
5Counting the days off by one
When the number of days between two dates is built from month lengths, one end of the span is left out or counted twice.
Wrong turn
Error here
January 1 is already used, so 31−1=3031 - 1 = 30 days remain in January. With 2828 for February and 1414 for March, the count is 30+28+14=7230 + 28 + 14 = 72, and (1+72) mod 7=3(1 + 72) \bmod 7 = 3, a Wednesday.
Right path
From January 1 to February 1 is 3131 days, to March 1 another 2828, and to March 15 another 1414, so 31+28+14=7331 + 28 + 14 = 73. Then (1+73) mod 7=74 mod 7=4(1 + 73) \bmod 7 = 74 \bmod 7 = 4, a Thursday.
Why it happensThe days left in January are counted without January 1, and the days in March are counted without March 15, so the two ends of the span are handled by different rules and one day goes missing.
How to checkTest the count on a short span. From January 1 to January 8 is 8−1=78 - 1 = 7 days, and January 8 falls on the same weekday as January 1.
Common pitfalls in modular arithmetic·/arithmetic/modulo/operationsLearn Math Class
Each slip reduces the wrong thing. A negative number takes the multiple of nn at or below it, an exponent is reduced by the length of the cycle of powers and not by the modulus, division is done before reducing or through an inverse, a remainder of 00 stands for the last place of a cycle, and a count of days measures the distance between dates, so January 1 to February 1 is 3131 days. Trying a small case worked out in full, or multiplying back, catches each slip.

Skills You Should Learn

Each skill opens its step-by-step method page. Skills marked "On this page" are taught above.
Taught on this page
More arithmetic methods
  • 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.
  • 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.

Modular Arithmetic FAQ

What is modular arithmetic?

+
Modular arithmetic is a system where numbers wrap around after reaching a modulus n. All operations stay within the set {0, 1, 2, ..., n-1}. Like a 12-hour clock where 10 + 5 = 3 (not 15), numbers cycle back when they exceed the modulus. Addition, subtraction, multiplication, and exponentiation all work inside this system; only division behaves differently.Read more →

How do you compute large powers modulo n?

+
Reduce after every multiplication instead of computing the full power first. For 7⁴ mod 10: compute 7² = 49 → 9, then 9 × 7 = 63 → 3, then 3 × 7 = 21 → 1. The largest intermediate is 63, not 2,401. For genuinely huge exponents, use the repeating cycle of powers instead of multiplying step by step.Read more →

How do you find the last two digits of a power?

+
The last two digits are the number mod 100. Find when the powers cycle mod 100. For 7⁵⁰ mod 100: since 7⁴ = 2401 ≡ 1 (mod 100), and 50 = 4×12 + 2, we get 7⁵⁰ ≡ 7² = 49 (mod 100). The last two digits are 49.Read more →

Can two nonzero numbers multiply to zero in modular arithmetic?

+
Yes, when the modulus is not prime. Modulo 1010, 2⋅5=10≡02 \cdot 5 = 10 \equiv 0 although neither factor is 00, and modulo 1212, 3⋅4≡03 \cdot 4 \equiv 0. This is why division does not carry over: 2⋅5≡2⋅0(mod10)2 \cdot 5 \equiv 2 \cdot 0 \pmod{10}, yet cancelling the 22 would give 5≡05 \equiv 0, which is false. Modulo a prime it never happens, because a prime cannot divide a product without dividing one of its factors.Read more →

Can you reduce the exponent modulo n?

+
No, the exponent is reduced by the length of the cycle of powers, not by nn. The exponent counts multiplications, and that count repeats with the cycle. For 2100 mod 72^{100} \bmod 7 the powers run 2,4,12, 4, 1 and repeat, so the cycle length is 33, and 100=3⋅33+1100 = 3 \cdot 33 + 1 gives 2100≡22^{100} \equiv 2. Reducing by 77 instead gives 22=42^2 = 4, which is wrong. A quick test: 27=128≡22^7 = 128 \equiv 2, not 20=12^0 = 1.Read more →

How can a computer raise a number to a 600-digit power?

+
By squaring and reducing after every step. Each squaring doubles the exponent, so ten squarings reach a1024a^{1024}, and any exponent is built from such squares by its binary digits. A 600600-digit exponent has about 2,0002{,}000 binary digits, so RSA encryption computes cd mod nc^d \bmod n in fewer than 4,1004{,}100 multiplications, each result reduced below nn. Written out in full, cdc^d would have more digits than there are atoms in the universe.Read more →