The Timpson Lyceum · Discrete Math (2025)
Modular Arithmetic, Chinese Remainder Theorem, and Factoring - Lecture 20 (Discrete Math)
Modular Arithmetic, Chinese Remainder Theorem, and Factoring – Lecture 20
Overview
This lecture completes the study of modular arithmetic and opens the topic of factoring. We define division in via multiplicative inverses, discover that — unlike on the real numbers — most elements have no inverse, and prove the central fact that an element is invertible exactly when it is relatively prime to . We then use the extended Euclidean algorithm to compute inverses (and hence divide) even in large moduli, solve single congruences and systems of congruences (the Chinese Remainder Theorem in action). Finally we introduce prime factorization, state the Fundamental Theorem of Arithmetic, and prove the prime-divisibility lemmas (Euclid's lemma and its generalization) that the uniqueness proof will rest on.
Key Concepts
The set . , the first natural numbers. Note the largest element is , one less than .
Addition and multiplication mod . Both operations piggyback on ordinary arithmetic and then reduce:
- in means — take the remainder after dividing by .
- in means .
Algebraic properties (for , so ). These are inherited from the reals:
- Associativity: and .
- Commutativity: and .
- Identities: (0 is the additive identity); (1 is the multiplicative identity); .
- Distributivity: .
Subtraction. Defined from addition: is the unique solving . It turns out , matching the way addition is defined.
Reciprocal / multiplicative inverse. For , we call the reciprocal (or inverse) of if . If such a exists, is invertible and we write .
Division. For with invertible, . The requirement " invertible" is the modular analog of "" on the reals — you cannot divide by something with no inverse. Why an inverse is needed: cancellation is valid only when has an inverse. (Example in : and , so "" is ambiguous — has no inverse.)
Inverses in . From the multiplication table, the invertible elements are :
- , (since ), , (since ).
- have no inverse — note even the prime fails. never has an inverse in any .
Uniqueness of inverses. If has a reciprocal, it has exactly one. Proof: suppose and both satisfy and . Then so . (This is why a appears at most once in any row or column of a multiplication table.) Taking the inverse twice returns the original: .
Invertibility criterion (the key theorem). is invertible if and only if (i.e. and are relatively prime).
- Forward: if in , then for some integer , i.e. . Bézout's identity says the smallest positive value of is ; getting forces .
- Backward: if then for some integers . Reducing mod kills , giving . Setting keeps and , so .
This rests on Bézout's identity — the lecture's "second most important theorem of number theory": for integers there exist integers with , and is the smallest positive value can take. (The "most important" is the Division Algorithm: .)
Computing inverses with the extended Euclidean algorithm. To find in : run Euclid's algorithm on and to confirm , then back-substitute to write . Reducing mod gives (add a multiple of to land in ).
Solving linear congruences.
- has all solutions , (infinitely many, spaced apart).
- : multiply both sides by (exists when ), giving .
Systems of congruences (Chinese Remainder Theorem). To solve and : substitute the general solution of the first () into the second, solve the resulting congruence for using an inverse, then back-substitute. With coprime moduli the combined solution is unique mod — the final answer has the form .
Factoring and the Fundamental Theorem of Arithmetic. Every positive integer factors into a unique product of primes, up to order. Examples: , , . The number is the empty product of primes (its unique, prime-free factorization); itself is not prime. Prime factorizations let you cancel cleanly, e.g. .
Euclid's lemma. If is prime and , then or . (False for composite divisors: but and .) Proof idea: if divides neither nor , then since 's only divisors are and , we get . Bézout gives and ; multiplying these, every term on the right is divisible by (each contains a factor of or the factor , which divides), so — impossible. Hence or .
Generalization to products of primes. If is prime and where each is prime, then for some . Proved by induction on : the base case forces (both have only trivial divisors); the inductive step splits via Euclid's lemma into — handled by the hypothesis — or , giving .
Worked Example
Compute in (i.e. find ), then use it to evaluate .
First run the Euclidean algorithm on and , recording remainders:
The last nonzero remainder is , so and is invertible. Back-substitute to write as a combination of and :
Reducing mod kills the term:
So . Now divide by using this inverse:
Therefore in .
Summary
- ; addition and multiplication are ordinary arithmetic followed by reducing mod , and they inherit associativity, commutativity, identities, and distributivity.
- Division is multiplication by a multiplicative inverse: , defined only when is invertible — the modular stand-in for "nonzero."
- An element is invertible in iff ; when an inverse exists it is unique. Inverses are computed by back-substituting the extended Euclidean algorithm.
- Linear congruences are solved by multiplying through by ; systems are solved by substitution, yielding (for coprime moduli) a unique solution modulo the product — the Chinese Remainder Theorem.
- The Fundamental Theorem of Arithmetic asserts every positive integer has a unique prime factorization (with as the empty product); cancellation via factorizations simplifies fractions.
- Euclid's lemma ( or for prime ) and its induction-based extension to products of primes are the divisibility tools that the uniqueness of factorization will be built on.