Math Demo ยท Browser-only

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.

Live Demo
4
Try it

a mod n, visualized.

0
14
5

14 mod 5 = 4

14 = 2 ร— 5 + 4

Where it shows up

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.

Where it came from

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 BCE โ€” Euclid's algorithm (gcd via remainders)
c. 300 CE โ€” Sun Tzu / Chinese Remainder Theorem
1801 โ€” Gauss, Disquisitiones Arithmeticae, โ‰ก notation
Tech stack
Vanilla JS Inline SVG No backend No dependencies