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}.
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 n possible remainders, and every operation stays within that set.
Add 9+7 in ordinary arithmetic and the answer is 16. Add 9+7 modulo 10 and the answer is 6 — the sum wraps past 9 and cycles back. The number 16 and the number 6 are different on the number line, but they are the same in the world of mod10.
The mental model is a clock with n hours. On a 10-hour clock, moving 7 steps forward from 9 lands on 6, not 16. On a 12-hour clock, 10+5=3, not 15. 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 a≡a′(modn) and b≡b′(modn), then:
a+b≡a′+b′(modn)
a−b≡a′−b′(modn)
a⋅b≡a′⋅b′(modn)
In words: replacing any number with a congruent one does not change the remainder of the result. The product 89×76 modulo 9 does not require computing 6,764 first — replacing 89 with 8 and 76 with 4 gives 32, and 32mod9=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 n:
(a+b)modn=((amodn)+(bmodn))modn
For (47+38)mod10: reduce 47 to 7 and 38 to 8. Add: 7+8=15. Reduce: 15mod10=5.
For (123+456)mod7: reduce 123 to 4 and 456 to 1. Add: 4+1=5. Since 5<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). For mod10, the largest possible intermediate sum is 9+9=18, which still needs one more reduction. But it can never reach 2n, 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.
(a−b)modn=((amodn)−(bmodn))modn
For (23−47)mod10: reduce 23 to 3 and 47 to 7. Subtract: 3−7=−4. The result is negative, so add n: −4+10=6.
The alternative is to compute the full subtraction first: 23−47=−24, then −24mod10=6 (using the floored convention). Either route gives 6.
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 n translates it to its equivalent position in {0,1,…,n−1}.
Multiplication
Modular multiplication reduces each factor, multiplies the remainders, and reduces the product:
(a⋅b)modn=((amodn)⋅(bmodn))modn
For (23⋅17)mod5: reduce 23 to 3 and 17 to 2. Multiply: 3⋅2=6. Reduce: 6mod5=1.
For (89⋅76)mod9: reduce 89 to 8 and 76 to 4. Multiply: 8⋅4=32. Reduce: 32mod9=5.
The savings are dramatic for large numbers. The product 89×76=6,764 is never needed — the same answer emerges from the product 8×4=32, a computation simple enough to do mentally.
The principle chains through multiple factors. For (13⋅17⋅19)mod5: reduce to 3⋅2⋅4=24, then 24mod5=4. Reduce at every step to keep the numbers small.
Powers
Computing akmodn by first calculating ak and then reducing is impractical — the intermediate number grows exponentially. Instead, reduce after every multiplication.
The answer is 1. The largest intermediate number was 63 — far smaller than 74=2,401.
For 310mod7:
31=3, 32=9→2, 33=6, 34=18→4, 35=12→5, 36=15→1.
At 36, the remainder returns to 1. From here: 310=36⋅34≡1⋅4=4(mod7).
Detecting Cycles in Powers
Because modn confines remainders to a finite set, the sequence of remainders a1,a2,a3,…modn must eventually repeat. Once a remainder reappears, the entire pattern cycles from that point forward.
Powers of 2mod7 produce the sequence: 2,4,1,2,4,1,2,4,1,… The cycle {2,4,1} has length 3 and repeats indefinitely.
To compute 2100mod7, divide the exponent by the cycle length: 100=3⋅33+1. The remainder is 1, so 2100 lands at the same position as 21 in the cycle. The answer is 2.
Powers of 3mod10 cycle through {3,9,7,1} with length 4. For 375mod10: 75=4⋅18+3, so 375 matches 33=7. The answer is 7.
The cycle always begins once the remainder 1 appears (assuming it does), because ak≡1 implies ak+j≡aj for any j — the sequence restarts.
Why Division Is Different
Addition, subtraction, and multiplication all pass through modn cleanly. Division does not.
Consider 12÷4=3. Working modulo 5: 12mod5=2 and 4mod5=4. Dividing the remainders gives 42=0.5 — not an integer, and certainly not 3mod5=3.
The problem is that division undoes multiplication, but modular reduction discards information that division needs to recover. The product 4⋅3=12 reduces to 2mod5, and knowing only 2 and 4 is not enough to reconstruct 3 through ordinary division.
Modular division requires a different tool: the modular inverse. The inverse of b modulo n is a number b−1 such that b⋅b−1≡1(modn). Dividing by b then means multiplying by b−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. Finding the last digit of a large power reduces to modular exponentiation with n=10.
Find the last digit of 7100. The powers of 7mod10 cycle: 7,9,3,1,7,9,3,1,… with period 4.
Divide the exponent by the cycle length: 100=4⋅25+0. A remainder of 0 means the exponent aligns with the end of a full cycle — the position of 74, whose last digit is 1.
Find the last digit of 375. The powers of 3mod10 cycle: 3,9,7,1 with period 4. Divide: 75=4⋅18+3. The remainder 3 points to the third position in the cycle: 7.
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 12-hour clock operates mod12. If it is 10:00 now, what time will it be in 50 hours? Compute (10+50)mod12=60mod12=0. On a 12-hour clock, a remainder of 0 corresponds to 12:00.
A 24-hour clock operates mod24. If it is 21:00 (9 PM), what time will it be in 100 hours? Compute (21+100)mod24=121mod24. Divide: 121=24⋅5+1. The answer is 1:00 — one o'clock in the morning.
The same logic handles backward calculations. If it is 3:00 now, what time was it 20 hours ago? Compute (3−20)mod12=−17mod12. Adding 24 (two full cycles): −17+24=7. It was 7:00.
Day of Week Problems
Days of the week cycle with period 7, making them a mod7 system. Assign numbers: Sunday =0, Monday =1, Tuesday =2, Wednesday =3, Thursday =4, Friday =5, Saturday =6.
Today is Wednesday (day 3). What day is it in 100 days? Compute (3+100)mod7=103mod7. Divide: 103=7⋅14+5. Day 5 is Friday.
January 1 is a Monday (day 1). What day is March 15? Count the days: 31 (remaining in January) +28 (February) +14 (first 14 days of March) =73 days later. Compute (1+73)mod7=74mod7. Divide: 74=7⋅10+4. Day 4 is Thursday.
Larger spans work identically. What day is it 1,000 days from a Tuesday (day 2)? Compute (2+1000)mod7=1002mod7. Divide: 1002=7⋅143+1. Day 1 is Monday.
Why Divisibility Rules Work
The familiar divisibility rules are modular arithmetic in disguise. Each rule exploits a congruence property of 10 — the base of our number system.
The digit-sum rule for 9 works because 10≡1(mod9). Every power of 10 is congruent to 1: 100=1, 101≡1, 102≡1, and so on. A digit d in the kth place contributes d⋅10k≡d⋅1=d(mod9). The place value drops away, and only the digit itself matters. So the entire number is congruent to the sum of its digits modulo 9.
The rule for 3 follows identically: 10≡1(mod3), so the digit sum also determines divisibility by 3.
The alternating-sum rule for 11 works because 10≡−1(mod11). Powers of 10 alternate: 100=1, 101≡−1, 102≡1, 103≡−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 10 modulo the divisor in question. Modular arithmetic is the engine; the rules are the user-facing controls.
Worked Examples
Compute (137⋅249)mod7. Reduce: 137mod7=4 and 249mod7=4. Multiply: 4⋅4=16. Reduce: 16mod7=2.
Find the last two digits of 750 (that is, 750mod100). Compute powers step by step: 71=7, 72=49, 74=492=2401→1mod100. Since 74≡1(mod100), and 50=4⋅12+2, we get 750≡72=49(mod100). The last two digits are 49.
A meeting happens every 8 days. Another happens every 12 days. Both occur today. When do they next coincide? The answer is the LCM of 8 and 12, which is 24 — but modular thinking frames it as: find the smallest d>0 such that d≡0(mod8) and d≡0(mod12).
Verify that 8,361 is divisible by 9. Digit sum: 8+3+6+1=18, then 1+8=9. Since 9≡0(mod9), the number is divisible by 9. Confirm: 8361=9⋅929.
Simplify (250+350)mod5. Powers of 2mod5 cycle {2,4,3,1} with period 4. Since 50=4⋅12+2, 250≡4(mod5). Powers of 3mod5 cycle {3,4,2,1} with period 4. Since 50=4⋅12+2, 350≡4(mod5). Sum: 4+4=8→8mod5=3.