Modular Arithmetic Clock

Choose modulus n and operation. See result on a modular clock and inspect addition/multiplication tables.

Loading interactive simulation...

Congruence relations and algebraic ring structures 🖖

Modular arithmetic deals with integers under a cyclic modulus n, written as a ≡ b (mod n). This algebraic system forms a commutative ring Z/nZ. If the modulus p is prime, the ring becomes a field, meaning every non-zero element has a multiplicative inverse. This structure underlies modern cryptography, cyclic codes, and clock arithmetic, demonstrating how numbers behave under periodic boundaries.

Why it is called clock arithmetic 🖖

On a 12-hour clock, 4 hours after 11 o'clock is 3, not 15 — the numbers wrap back to the start once they pass 12. That is exactly modular arithmetic: a ≡ b (mod n) means a and b leave the same remainder when divided by n. So 15 ≡ 3 (mod 12). The core takeaway: modular arithmetic keeps only the remainder after division, and this tool's clock lets you watch the numbers loop around.

The nine-divisibility trick is hidden modular arithmetic 🖖

The old rule "a number is divisible by 9 if its digits sum to a multiple of 9" is pure modular arithmetic. Because 10 ≡ 1 (mod 9), every power of 10 is also ≡ 1, so any number is congruent to the sum of its digits (mod 9). The same fact powers "casting out nines", a centuries-old way to check arithmetic by hand.

Example problems

  • clock mod 12 - Clock arithmetic: 13 ≡ 1 (mod 12), so 13+5 wraps to 6.
  • prime mod 7 - Prime modulus: nonzero multiplication rows behave as permutations.
  • composite mod 6 - Composite modulus shows repeating rows where gcd(row,n) > 1.
  • fermat mod 13 - Fermat-style pattern: a^(p-1) ≡ 1 mod p for prime p and gcd(a,p)=1.