Skip to content

Modular arithmetic, explained

5 min read

Short answer

a≡b(modn)a\equiv b\pmod n means nn divides a−ba-b: aa and bb leave the same remainder after division by nn. Congruences can be added, subtracted and multiplied like equations, so you can reduce at every step and keep the numbers small.

Bar chart01234Powers of 3 mod 5: 3⁰, 3¹, 3², 3³, 3⁴ = 1, 3, 4, 2, 1 (cycle length 4).
Powers repeat in a cycle, which makes huge exponents manageable.

The rules

If a≡ba\equiv b and c≡d(modn)c\equiv d\pmod n, then a+c≡b+da+c\equiv b+d, a−c≡b−da-c\equiv b-d and ac≡bdac\equiv bd. Division is the exception: you can cancel cc only when gcd⁡(c,n)=1\gcd(c,n)=1.

Where it is used

Clocks ( mod 12\bmod12), days of the week ( mod 7\bmod7), check digits, hash functions and public-key cryptography all rely on arithmetic modulo nn. Divisibility by 99: a number is congruent to the sum of its digits mod 99.

Worked example

Find the remainder of 31003^{100} when divided by 55.

Powers of 33 mod 55 cycle: 3,4,2,13,4,2,1 (period 44). Since 100=4⋅25100=4\cdot25, 3100=(34)25≡125=1(mod5)3^{100}=(3^4)^{25}\equiv1^{25}=1\pmod5. The remainder is 11.

Try it yourself

What is 7⋅9+57\cdot9+5 mod 44, reducing before you multiply?

Show the answer

7≡37\equiv3 and 9≡19\equiv1, so 7⋅9≡37\cdot9\equiv3. Then 3+5=8≡03+5=8\equiv0. The result is 00 (check: 63+5=68=4⋅1763+5=68=4\cdot17).

Keep going with practice

Vidi's study guides remind you to check answers by an independent route; remainders are a quick sanity check.