All courses › Discrete Mathematics › Modular arithmetic

Modular arithmetic

Modular arithmetic is about the remainder after integer division, like a clock that starts over. Two numbers are congruent modulo n if they leave the same remainder. It is used in check digits, hashing and cryptography.

a≡b(modn)a \equiv b \pmod na and b leave the same remainder when divided by n
(a⋅b) mod n=((a mod n)(b mod n)) mod n(a\cdot b) \bmod n = ((a \bmod n)(b \bmod n)) \bmod nwork with remainders along the way

Symbols

 mod \bmodremainder of integer division
nnmodulus

Example

Which weekday is it in 100 days if today is Monday?

100 mod 7=2100 \bmod 7 = 2, so it will be Wednesday.

Reduce the numbers along the way, so you never have to handle huge numbers.
Practise graphs and modular arithmetic for free →

← Graphs · Greatest common divisor →

Part of Discrete Mathematics: Graphs and modular arithmetic.