MATH 324 Summer 2012 Elementary Number Theory Notes on Systems of Linear Congruences In this note we will discuss systems of linear congruences where the moduli are all different. Definition. Given the system of linear congruences a 1 x b 1 (mod m 1 ) a 2 x b 2 (mod m 2 ). ( ) a n x b n (mod m n ) an integer x 0 is a solution of this system if and only if it is a solution of each of the congruences in the system. The system ( ) above can be solved iteratively, as the next example shows. Example 1. Solve the following system of linear congruences x 1 (mod 2) x 2 (mod 3) x 3 (mod 5) Solution. We write the first congruence as an equality x = 2t + 1 for some integer t, and then substitute this into the second congruence to get 2t + 1 2 (mod 3), that is, Since the inverse of 2 modulo 3 is 2 we get 2t 1 (mod 3). t 2 (mod 3). Next we write this congruence as an equality t = 3k + 2 for some integer k, so that x = 2t + 1 = 6k + 4 + 1 = 6k + 5. Substituting this into the third congruence, we get 6k + 5 3 (mod 5), that is, so that 6k 2 3 (mod 5), k 6k 3 (mod 5).
Writing this last congruence as an equality, we have k = 5l + 3, so that x = 6k + 5 = 30l + 18 + 5 = 23 + 30l, and the solution to the system of linear congruences is x 23 (mod 30). Before stating the Chinese Remainder Theorem, we need some preliminary results concerning the least common multiple of two or more positive integers. Definition. If a, b, and m are nonzero integers with m > 0, then m is called a common multiple of a and b if and only if a m and b m. Note: This definition has meaning only if a 0 and b 0 since division by zero is meaningless. Clearly, ab and ab are common multiples of a and b and by the law of trichotomy at least one of them is positive, so by the well-ordering principle there must exist a smallest positive common multiple of a and b, and we have the following definition. Definition. If m is the smallest positive common multiple of the integers a and b, it is called the least common multiple of a and b, and is denoted by [a, b] or lcm(a, b). Recall that the definition of the greatest common divisor was given in terms of the order properties of the integers, but we gave an equivalent definition in terms of divisibilty only. The same can be done for the least common multiple, and we have the following theorem. Theorem. If a, b, and m are nonzero integers with m > 0, then m = [a, b] if and only if (i) a m and b m, and (ii) whenever k is a common multiple of a and b, then m k. Proof. Suppose that m = [a, b] and k is any common multiple of a and b. By definition, m > 0, and a m and b m, so we need only show that m k. We can assume without loss of generality that k > 0, thus m k since m is the least common multiple of a and b. Now, from the division algorithm we can write k = q m + r, where q and r are integers and 0 r < m, and therefore r = k q m. Since k and m are common multiples of a and b, then a r and b r, so that r is a common multiple of a and b, thus, if r > 0, this contradicts the fact that m is the least common multiple of a and b. Therefore, we must have r = 0, that is, k = q m, so that m k. Conversely, suppose that m > 0, a m and b m, and that m k for every common multiple of a and b. Since m is a positive common multiple of a and b and for any common multiple k of a and b, we have m k, then we must have m k. Therefore m is the least positive multiple of a and b, that is, m = [a, b].
Thus, we have the following result: Theorem. If a, b, and c are nonzero integers, then [a, b] c if and only if a c and b c. We define the least common multiple of any finite set of nonzero integers m 1, m 2,..., m k in a similar fashion and denote it by [m 1, m 2,..., m k ], and we have the following lemma: Lemma. If m 1, m 2,..., m k are positive integers, then [m 1, m 2,..., m k ] = [ [m 1, m 2,..., m k 1 ], m k ]. Proof. Let d = [m 1, m 2,..., m k ] and e = [ ] [m 1, m 2,..., m k 1 ], m k, then d > 0 and e > 0. We will show that d e and e f. Since d = [m 1, m 2,..., m k ], then m i d for i = 1, 2,..., k, so that by the preceding theorem [m 1, m 2,..., m k 1 ] d and mk d, and the preceding theorem again implies that e d. Conversely, m k e and [m1, m 2,..., m k 1 ] e, so that m i e for i = 1, 2,..., k, so that [m1, m2,..., mk] e, that is, d e. Now we can prove the following theorem: Theorem. If m 1, m 2,..., m k are positive integers and a and b are integers, and a b (mod m 1 ), a b (mod m 2 ),... a b (mod m k ), then a b (mod [m 1, m 2,..., m k ]). Proof. If a b (mod m 1 ) and a b (mod m 2 ), then m 1 a b and m2 a b, which implies that [m 1, m 2 ] a b, so that a b (mod [m 1, m 2 ]). Now, a b (mod [m 1, m 2 ]) and a b (mod m 3 ), which implies as above that a b (mod [ ] [m 1, m 2 ], m 3 ) b (mod [m1, m 2, m 3 ]). Continuing in this manner, we see that a b (mod [m 1, m 2,..., m k ]).
Corollary. If a b (mod m 1 ), a b (mod m 2 ),... a b (mod m k ), where m 1 > 0, m 2 > 0,..., m k > 0 are pairwise relatively prime, then a b (mod m 1 m 2 m k ). Proof. Since (m 1, m 2 ) = 1, then m 1 m 2 = [m 1, m 2 ] (m 1, m 2 ) = [m 1, m 2 ]. Similarly, since ([m 1, m 2 ], m 3 ) = (m 1 m 2, m 3 ) = 1, then m 1 m 2 m 3 = [ ] [m 1, m 2 ], m 3 (m1 m 2, m 3 ) = [ ] [m 1, m 2 ], m 3 = [m1, m 2, m 3 ]. And now and easy induction argument shows that when (m i, m j ) = 1 for i j. [m 1, m 2,..., m k ] = m 1 m 2 m k Returning to the systems of linear congruences, we have the following theorem: Theorem. The system of congruences has a solution if and only if (m, n) a b. x a (mod m) x b (mod n) If this is the case and if x 0 is any particular solution to this system, then the general solution to this system is x x 0 (mod [m, n]). Proof. Note that x 0 is a solution to the system if and only if there is an integer k such that x 0 = a + km and a + km b (mod n), and this is true if and only if km a b (mod n). Thus, a solution exists if and only if (m, n) a b. Now suppose that (m, n) a b and that x0 is a solution to the system of congruences. If x 1 is also a solution, then x 1 a x 0 (mod m) x 1 b x 0 (mod n), so that x 1 x 0 is a common multiple of m and n, that is, m x 1 x 0 and n x 1 x 0, and therefore [m, n] x1 x 0, that is x 1 x 0 (mod [m, n]) and any two solutions are congruent modulo [m, n].
Conversely, if x 1 x 0 (mod [m, n]) then x 1 x 0 (mod m) a (mod m) and x 1 x 0 (mod n) b (mod n) so that x 1 is also a solution to the system of linear congruences. Therefore the general solution is x x 0 (mod [m, n]). Corollary 1. The system of linear congruences x a 1 (mod m 1 ) x a 2 (mod m 2 ). x a n (mod m n ) has a solution if and only if (m j, m k ) aj a k for each pair of subscripts j, k. If this is the case, and if x 0 is a solution, the general solution is x x 0 (mod [m 1, m 2,..., m n ]). Corollary 2. (Chinese Remainder Theorem) Suppose that m 1, m 2,..., m n are pairwise relatively prime, that is, (m i, m j ) = 1 for i j. Let M = m 1 m 2 m n and M k = M/m k for k = 1, 2,..., n. Let y k be the unique solution of y k M k 1 (mod m k ) for k = 1, 2,..., n, then the general solution to the system x a 1 (mod m 1 ) x a 2 (mod m 2 ). x a n (mod m n ) is given by x a 1 y 1 M 1 + a 2 y 2 M 2 + + a n y n M n (mod M). We now return to the first example of a system of linear congruences which we solved iteratively and use the Chinese Remainder Theorem to find the solution again. Example 2. Solve the following system of linear congruences x 1 (mod 2) x 2 (mod 3) x 3 (mod 5).
Solution. Here we have a 1 = 1, a 2 = 2, and a 3 = 3. Also, m 1 = 2, m 2 = 3, m 3 = 5, so that M = 2 3 5 = 30, and M 1 = M m 1 = 30 2 = 15, M 2 = M m 2 = 30 3 = 10, M 3 = M m 3 = 30 5 = 6. Solving the congruences y k M k 1 (mod m k ) for k = 1, 2, 3, we have 15y 1 1 (mod 2) implies y 1 1 (mod 2) 10y 2 1 (mod 3) implies y 2 1 (mod 3) 6y 3 1 (mod 5) implies y 3 1 (mod 5), therefore the general solution to the system is x a 1 y 1 M 1 + a 2 y 2 M 2 + a 3 y 3 M 3 1 15 + 2 10 + 3 6 23 (mod 30), which is the same as the solution obtained previously.