Modulo Arithmetic
The remainder operation behind clocks, calendars, cryptography, hash tables, and checksums. Drag the sliders below and watch a number wrap around a dial โ that wraparound is the whole idea.
a mod n, visualized.
14 mod 5 = 4
14 = 2 ร 5 + 4
Same trick, six disguises.
Clocks & calendars
14:00 is really 14 mod 12. Day-of-week formulas (Zeller's congruence) find weekdays for any date the same way โ wrapping through mod 7.
Cryptography
RSA and Diffie-Hellman both do all their exponentiation "mod n" against huge numbers โ easy forward, practically impossible to reverse without the key.
Hash tables
A hash function maps a key to a huge number; mod bucket-count squeezes it into a valid array index in constant time.
Checksums
ISBNs, credit cards (Luhn), and barcodes all append a check digit computed mod 10 or mod 11 โ catching typos and scan errors instantly.
Music theory
Pitches repeat every 12 semitones. Two notes an octave apart are "the same" mod 12 โ the entire circle-of-fifths lives in this arithmetic.
Circular buffers
Ring buffers, round-robin schedulers, and pseudorandom generators (LCGs) all advance an index with (i + 1) % n to wrap cleanly back to zero.
Older than "equals," newer than you'd think.
From Euclid to Gauss
Remainder-based reasoning goes back to Euclid's algorithm for the greatest common divisor, and the 3rd-century Chinese Remainder Theorem, which solved puzzles like "find a number that leaves remainder 2 mod 3, 3 mod 5, and 2 mod 7" โ centuries before anyone wrote it symbolically.
The formal notation is much younger. Carl Friedrich Gauss introduced the โก congruence symbol and systematized "clock arithmetic" in Disquisitiones Arithmeticae (1801), turning a scattered set of tricks into a proper branch of number theory that modern computing now leans on constantly.
c. 300 CE โ Sun Tzu / Chinese Remainder Theorem
1801 โ Gauss, Disquisitiones Arithmeticae, โก notation