Modular Arithmetic

17 = 5 (mod 12)
17 and 5 leave the same remainder when divided by 12

Modular arithmetic is arithmetic on a circle. Two numbers are congruent modulo n if they differ by a multiple of n. A clock does arithmetic mod 12: 10 hours after 5 o'clock is 3, not 15. This simple idea underlies all modern cryptography, hash functions, error-correcting codes, and much of number theory.

The mod 12 clock: addition wraps around
1 2 3 4 5 6 7 8 9 10 11 12 17 mod 12 = 5 17 = 1 × 12 + 5
Fermat's Little Theorem verification
a^(p−1) ≡ 1 (mod p) when p is prime, p∤a
Example p=5, a=2: 2⁴ = 16 = 3×5 + 1 ≡ 1 (mod 5) ✓
Example p=7, a=3: 3⁶ = 729 = 104×7 + 1 ≡ 1 (mod 7) ✓
Used in RSA encryption to prove decryption recovers the original message.
Addition table for ℤ/5ℤ (integers mod 5)

Every row and column contains {0,1,2,3,4} exactly once. The five elements form a closed group under addition mod 5. Red: sums that wrap around (≥5).

+01234
001234
112340
223401
334012
440123
Related topics
Primes Perfect Numbers Number Systems
Key facts about Modular Arithmetic

Modular arithmetic defines congruence: a is congruent to b mod n if n divides a-b. Gauss systematised it in 1801. It underlies all modern public-key cryptography: RSA encryption relies on Fermat's Little Theorem, which states that a^(p-1) is congruent to 1 mod p for any prime p not dividing a. Hash functions use modular operations to map large inputs to fixed-size outputs. The integers mod n form a complete ring, and when n is prime, a finite field.

Kaytetaan
Matematiikka
Fysiikka
Insinooritiede
🧬Biologia
💻Tietojenkasittely
📊Tilastotiede
📈Rahoitus
🎨Taide
🏛Arkkitehtuuri
Musiikki
🔐Kryptografia
🌌Tahttitiede
Kemia
🦉Filosofia
🗺Maantiede
🌿Ekologia
Want to test your knowledge?
Question
What is modular exponentiation and why is it fast?
tap · space
1 / 10