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,,n1}\{0, 1, 2, \ldots, n-1\}.



Operating Within a Modulus

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.

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 mod10\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.

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: if aa(modn)a \equiv a' \pmod{n} and bb(modn)b \equiv b' \pmod{n}, then:

a+ba+b(modn)a + b \equiv a' + b' \pmod{n}


abab(modn)a - b \equiv a' - b' \pmod{n}


abab(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 32mod9=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:

(a+b)modn=((amodn)+(bmodn))modn(a + b) \bmod n = ((a \bmod n) + (b \bmod n)) \bmod n


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

For (123+456)mod7(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(n1)2(n - 1). For mod10\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.

Subtraction

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

(ab)modn=((amodn)(bmodn))modn(a - b) \bmod n = ((a \bmod n) - (b \bmod n)) \bmod n


For (2347)mod10(23 - 47) \bmod 10: reduce 2323 to 33 and 4747 to 77. Subtract: 37=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: 2347=2423 - 47 = -24, then 24mod10=6-24 \bmod 10 = 6 (using the floored convention). Either route gives 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,,n1}\{0, 1, \ldots, n-1\}.

Multiplication

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

(ab)modn=((amodn)(bmodn))modn(a \cdot b) \bmod n = ((a \bmod n) \cdot (b \bmod n)) \bmod n


For (2317)mod5(23 \cdot 17) \bmod 5: reduce 2323 to 33 and 1717 to 22. Multiply: 32=63 \cdot 2 = 6. Reduce: 6mod5=16 \bmod 5 = 1.

For (8976)mod9(89 \cdot 76) \bmod 9: reduce 8989 to 88 and 7676 to 44. Multiply: 84=328 \cdot 4 = 32. Reduce: 32mod9=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 (131719)mod5(13 \cdot 17 \cdot 19) \bmod 5: reduce to 324=243 \cdot 2 \cdot 4 = 24, then 24mod5=424 \bmod 5 = 4. Reduce at every step to keep the numbers small.

Powers

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

For 74mod107^4 \bmod 10, build the power step by step:

71mod10=77^1 \bmod 10 = 7

72=77=4949mod10=97^2 = 7 \cdot 7 = 49 \to 49 \bmod 10 = 9

73=97=6363mod10=37^3 = 9 \cdot 7 = 63 \to 63 \bmod 10 = 3

74=37=2121mod10=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.

For 310mod73^{10} \bmod 7:

31=33^1 = 3, 32=923^2 = 9 \to 2, 33=63^3 = 6, 34=1843^4 = 18 \to 4, 35=1253^5 = 12 \to 5, 36=1513^6 = 15 \to 1.

At 363^6, the remainder returns to 11. From here: 310=363414=4(mod7)3^{10} = 3^6 \cdot 3^4 \equiv 1 \cdot 4 = 4 \pmod{7}.

Detecting Cycles in Powers

Because modn\bmod n confines remainders to a finite set, the sequence of remainders a1,a2,a3,modna^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 2mod72 \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.

To compute 2100mod72^{100} \bmod 7, divide the exponent by the cycle length: 100=333+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.

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

The cycle always begins once the remainder 11 appears (assuming it does), because ak1a^k \equiv 1 implies ak+jaja^{k+j} \equiv a^j for any jj — the sequence restarts.

Why Division Is Different

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

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

The problem is that division undoes multiplication, but modular reduction discards information that division needs to recover. The product 43=124 \cdot 3 = 12 reduces to 2mod52 \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 b1b^{-1} such that bb11(modn)b \cdot b^{-1} \equiv 1 \pmod{n}. Dividing by bb then means multiplying by b1b^{-1}. Not every number has an inverse for every modulus — the theory belongs to number theory and is not covered here.

Last Digit Problems

The last digit of any number is that number mod10\bmod 10. Finding the last digit of a large power reduces to modular exponentiation with n=10n = 10.

Find the last digit of 71007^{100}. The powers of 7mod107 \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=425+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.

Find the last digit of 3753^{75}. The powers of 3mod103 \bmod 10 cycle: 3,9,7,13, 9, 7, 1 with period 44. Divide: 75=418+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.

Clock Problems

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

A 1212-hour clock operates mod12\bmod 12. If it is 10:0010{:}00 now, what time will it be in 5050 hours? Compute (10+50)mod12=60mod12=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 mod24\bmod 24. If it is 21:0021{:}00 (9 PM), what time will it be in 100100 hours? Compute (21+100)mod24=121mod24(21 + 100) \bmod 24 = 121 \bmod 24. Divide: 121=245+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 (320)mod12=17mod12(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 mod7\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.

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

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)mod7=74mod7(1 + 73) \bmod 7 = 74 \bmod 7. Divide: 74=710+474 = 7 \cdot 10 + 4. Day 44 is Thursday.

Larger spans work identically. What day is it 1,0001{,}000 days from a Tuesday (day 22)? Compute (2+1000)mod7=1002mod7(2 + 1000) \bmod 7 = 1002 \bmod 7. Divide: 1002=7143+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.

The digit-sum rule for 99 works because 101(mod9)10 \equiv 1 \pmod{9}. Every power of 1010 is congruent to 11: 100=110^0 = 1, 101110^1 \equiv 1, 102110^2 \equiv 1, and so on. A digit dd in the kkth place contributes d10kd1=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 rule for 33 follows identically: 101(mod3)10 \equiv 1 \pmod{3}, so the digit sum also determines divisibility by 33.

The alternating-sum rule for 1111 works because 101(mod11)10 \equiv -1 \pmod{11}. Powers of 1010 alternate: 100=110^0 = 1, 101110^1 \equiv -1, 102110^2 \equiv 1, 103110^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 (137249)mod7(137 \cdot 249) \bmod 7. Reduce: 137mod7=4137 \bmod 7 = 4 and 249mod7=4249 \bmod 7 = 4. Multiply: 44=164 \cdot 4 = 16. Reduce: 16mod7=216 \bmod 7 = 2.

Find the last two digits of 7507^{50} (that is, 750mod1007^{50} \bmod 100). Compute powers step by step: 71=77^1 = 7, 72=497^2 = 49, 74=492=24011mod1007^4 = 49^2 = 2401 \to 1 \bmod 100. Since 741(mod100)7^4 \equiv 1 \pmod{100}, and 50=412+250 = 4 \cdot 12 + 2, we get 75072=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 d0(mod8)d \equiv 0 \pmod{8} and d0(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 90(mod9)9 \equiv 0 \pmod 9, the number is divisible by 99. Confirm: 8361=99298361 = 9 \cdot 929.

Simplify (250+350)mod5(2^{50} + 3^{50}) \bmod 5. Powers of 2mod52 \bmod 5 cycle {2,4,3,1}\{2, 4, 3, 1\} with period 44. Since 50=412+250 = 4 \cdot 12 + 2, 2504(mod5)2^{50} \equiv 4 \pmod{5}. Powers of 3mod53 \bmod 5 cycle {3,4,2,1}\{3, 4, 2, 1\} with period 44. Since 50=412+250 = 4 \cdot 12 + 2, 3504(mod5)3^{50} \equiv 4 \pmod{5}. Sum: 4+4=88mod5=34 + 4 = 8 \to 8 \bmod 5 = 3.