kbx+Eknhv57bYGKId/5XLsRvcR5o1oDr7hd99LfI0Y7ZE1eQAEJXTT+qiRTFQ4Vn/O8xKzn2h13i8WpgmgrbMZb+vglEe/2LLIMhSvVeYiqZHgPQiSt9jRswg8J/R2e5lCl21ctmQDLZo4n1kxbVogU4EYj5/jOA9I4R6AKYsM7n5Btct0XZYyWdnHVuEaIeYdEN9tHHf3QZb3ttXLGHbUkmYliAi/uYHURcog/AeVhpz/QI/NWCO+kRjBl+hEcAGFi2CmhLt506/pIaTzQ8Jr85gv/s0oEF0T+icl/3RwmUrMa14+x7gcZVnfWmdlDHsbL/E/NDwjOuzmDU8QQFOhdfkm6m8dSjpl0ftW0Fax1g+Bm2ZTaGjjjrYe1wDtvOo4qKr0BLBJhs7DPckJa1gOqv8QchoGbBkCSBGGAGN4GTpMDofyihdHnZwFt2viXEv6skwEIAtdoxdCgHFYxzFWtJxhbkOhGcmC2dXQMNXUD6H8wCb/ehPA103PgBceI1QLE4tJT7i5W9k5J1YPZaIKxJ8IQ0AwehiOtrPWgLCgqTMGoAp/21egaOdx4lkSvnRlEcBq6OBCnu45N6YP+YJWOVnxhUVTljbVxsZVH/I8CIgwq6VDXUuES/pwifa4eRoy6RCZUEvmPaAYOfJbEzGkZFOIv9cbvZoPVwDEW86eJSP4BA/ff+UC0ZmTpylhua6G8xqzl2h51GVOSu14pPOGxtJo6IRIgeJLTosWx/fz0XljT1AhZ3ZOkr

Modular Arithmetic

Clock arithmetic — the mathematics of remainders and cyclic patterns.

Congruences

a ≡ b (mod m) means m divides (a − b)
Equivalently: a mod m = b mod m

Modular arithmetic partitions integers into equivalence classes. For example, mod 12 gives us clock arithmetic (17:00 ≡ 5:00). The concept connects to solving equations but in a finite number system.

Modular Operations

(a + b) mod m = ((a mod m) + (b mod m)) mod m
(a · b) mod m = ((a mod m) · (b mod m)) mod m
aⁿ mod m → use repeated squaring (fast exponentiation)

Example: 7¹³ mod 11

7¹ = 7, 7² = 49 ≡ 5, 7⁴ ≡ 5² = 25 ≡ 3, 7⁸ ≡ 3² = 9

7¹³ = 7⁸ · 7⁴ · 7¹ ≡ 9 · 3 · 7 = 189 ≡ 2 (mod 11)

X4S5zonrbnKdEMC1jAQAdUP1udMk6bq6pyFft+AFOiFCdR0ZmQqkiAkdtungC8b3lPlYaybaE49HFqxwCkvGtLdMxwzrz8Qw71GD359ixbfgdoA16r1dVa/WVdnbMXifhwhNGOcDrFOUmFTk9H9jW6jOdZLI/t4mJxfr5jXAzgTGqUbHWiqBi+9Fku5hj8bmCxRJVI1qVbCK1z9Ck/PH+GCpzIOsYMJxq8t4/WihWemM687dOChsTRAIjaQKQvv1ywENcDiyDh/IELbGGV0zCngHU/xKWh0pF0nt+jU0Hen7EIpaxT7H63bOEr3BZh+q0MHltnPGGZwZr5SKibBxACrWVKTKmxUx3TBx8YRS5ioTFy2gHRpiPzXUPjQsUtK07CVfIyjeX4th1XgrU0rkaptAz/cOo321lrZVZFVwv+95hVF5mJC+u7KjrrvnMDXOr7pWxGMHY4mTCqkcauzyFGMYn5I+6rFKQeYUJZAKbni44xdzbkNdfezNtPdgzPYE/tmA22BoUzUZLBMMB1UzRRz+pGgn6k0oMI6OAwQc4fKssE655RmQgGMF58ZT5XGOaqeTkSSVE3VuuaIf7sTzXKTEdS7AHsOk+Y+aauTHVdGFpIDD5D2dTD4b3HRFMDTrBi7ntBrcxYuvnS2rzQHV9xDfINsSldyYlTalIIpZYPRX9EarhugzDSInp1Gm6hdTqEI6z1zvHe2v2/K2tlcRWxmGhyi2dI4LNUB/vWqN+St4axOCRPnHH1RS

Modular Inverse

The modular inverse of a (mod m) is x such that a·x ≡ 1 (mod m). It exists if and only if GCD(a, m) = 1 (a and m are coprime). Found via the Extended Euclidean Algorithm — see GCD computation.

This is essential for division in modular arithmetic and for RSA decryption.

Fermat & Euler

Fermat's Little Theorem: aᵖ⁻¹ ≡ 1 (mod p) if p is prime and gcd(a,p) = 1
Euler's Theorem: a^φ(n) ≡ 1 (mod n) if gcd(a,n) = 1
Euler's totient: φ(n) = n · ∏(1 − 1/p) for each prime p dividing n

Fermat's theorem is a special case of Euler's (since φ(p) = p − 1). These are the theoretical backbone of RSA encryption. The exponential functions connect to the structure of multiplicative groups mod n.

Chinese Remainder Theorem

If m₁, m₂, …, mₖ are pairwise coprime, then:
x ≡ a₁ (mod m₁), x ≡ a₂ (mod m₂), …, x ≡ aₖ (mod mₖ)
has a unique solution mod (m₁·m₂·…·mₖ)
CRT says you can reconstruct a number from its remainders — like reassembling a puzzle from pieces. This has applications in computer science (parallel computation), cryptography (speeding up RSA), and even calendar calculations.