Discrete Mathematics and Proof

The Chinese remainder theorem

A number leaves remainder 2 on division by 5, remainder 3 on division by 7 and remainder 4 on division by 9. Is there such a number, how do we find it, and how much do the three remainders pin it down?

Where you are 7 in Modular arithmetic

Why this exists

Knowing the remainder of x on division by 5 pins x down modulo 5; knowing it on division by 7 pins it down modulo 7. Do the two together pin x down modulo 35, and can any pair of remainders occur? The opening question asks this for three divisors: is there an x with

\begin{aligned} x &\equiv 2 \pmod{5}, \\ x &\equiv 3 \pmod{7}, \\ x &\equiv 4 \pmod{9}, \end{aligned}

and if so, how many? The answer is yes, exactly one modulo 5 \cdot 7 \cdot 9 = 315, and the proof builds it with the inverses of Modular inverses and linear congruences. A problem of this kind, a number to be found from its remainders, appears in the Sunzi Suanjing, a Chinese arithmetic text from the 3rd to 5th century, hence the name. Day 1 treats coprime moduli; day 2 drops that condition and recasts the theorem as a correspondence between \mathbb{Z}_{mn} and pairs.

Definition

Moduli are integers at least 2. As in Relations, equivalence classes and partitions, \mathbb{Z}_n is written as the remainders 0, 1, \dots, n - 1, each standing for its class.

Day 1: systems and pairwise coprime moduli

A system of congruences in the unknown x is a list

\begin{aligned} x &\equiv a_1 \pmod{m_1}, \\ &\ \ \vdots \\ x &\equiv a_k \pmod{m_k}. \end{aligned}

A solution is an integer x satisfying all of them at once. The moduli are pairwise coprime when \gcd(m_i, m_j) = 1 for every i \ne j. For example 5, 7, 9 are pairwise coprime, while 6, 10, 15 are not, although no prime divides all three.

Day 2: the correspondence

For moduli m and n, define \varphi : \mathbb{Z}_{mn} \to \mathbb{Z}_m \times \mathbb{Z}_n (a map into the Cartesian product) by

\varphi(x) = (x \bmod m,\ x \bmod n).

It records the two remainders of x and forgets x itself.

Intuition

Run through the numbers that are 2 modulo 5 below 35 and reduce each modulo 7:

x271217222732
x \bmod 72053164

Each step adds 5, a unit modulo 7, so the seven numbers meet every remainder modulo 7 exactly once, and exactly one, x = 17, is also 3 modulo 7. So every pair of remainders modulo 5 and 7 occurs once among 0, \dots, 34.

For moduli 3 and 4, place each x from 0 to 11 in the row of x \bmod 3 and the column of x \bmod 4:

\bmod 4 = 0123
\bmod 3 = 00963
141107
285211

Every cell holds exactly one number: \varphi is a bijection. With moduli 4 and 6, which share the factor 2, half the grid stays empty: x has the parity of both its remainders, so a row and a column of different parity never meet.

0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 0 1 2 3
x \bmod 6
x \bmod 4
Figure 1Each x from 0 to 11 placed by its remainders modulo 4 and modulo 6. Since \gcd(4, 6) = 2, a row and a column meet in a number only when they have the same parity; half the cells stay empty, and the pattern repeats every \operatorname{lcm}(4, 6) = 12, not every 24.

Results

Theorem 1 (two coprime moduli). Let \gcd(m, n) = 1. For any integers a and b the system x \equiv a \pmod{m}, x \equiv b \pmod{n} has a solution. If x_0 is one, the solutions are exactly the integers x \equiv x_0 \pmod{mn}.

Theorem 2 (the Chinese remainder theorem). Let m_1, \dots, m_k be pairwise coprime, let M = m_1 m_2 \cdots m_k and M_i = M / m_i. Then \gcd(M_i, m_i) = 1, so M_i has an inverse y_i modulo m_i, and

x_0 = a_1 M_1 y_1 + \dots + a_k M_k y_k

solves x \equiv a_i \pmod{m_i} for every i. The solutions are exactly the integers x \equiv x_0 \pmod{M}: one solution modulo M.

Theorem 3 (any two moduli). Let d = \gcd(m, n) and L = \operatorname{lcm}(m, n). The system x \equiv a \pmod{m}, x \equiv b \pmod{n} has a solution if and only if d \mid (a - b). When it does, the solutions are exactly one class modulo L.

Theorem 4 (the correspondence). If \gcd(m, n) = 1, the map \varphi is a bijection from \mathbb{Z}_{mn} to \mathbb{Z}_m \times \mathbb{Z}_n. It respects arithmetic: the remainders of x + y and of xy modulo m and modulo n are found from those of x and y alone, coordinate by coordinate.

Why it is true

The tools are Bezout’s identity and Euclid’s lemma from Bezout's identity and the extended Euclidean algorithm, and Theorems 5 and 6 of Modular inverses and linear congruences on solving ax \equiv c \pmod{n}. Each proof builds a solution (Existence proof), then shows any two solutions agree.

Lemma. If \gcd(m, n) = 1, m \mid c and n \mid c, then mn \mid c.

Proof. Bezout gives integers u, v with mu + nv = 1, so c = cmu + cnv. Write c = ns and c = mt. Then cmu = mn(su) and cnv = mn(tv), so mn divides both terms and their sum. \square

Proof of Theorem 1. Every x = a + mk with k \in \mathbb{Z} satisfies the first congruence, and every solution of it has this form. Such an x satisfies the second exactly when mk \equiv b - a \pmod{n}. Since \gcd(m, n) = 1, this has the solution k \equiv m^{-1}(b - a), so x = a + mk solves both. If x and x' are solutions, then x \equiv a \equiv x' \pmod{m} and x \equiv b \equiv x' \pmod{n}, so m and n divide x - x', and by the lemma mn \mid x - x'. Conversely, if x' = x + mnt, then x' \equiv x modulo m and modulo n, so x' is a solution. \square

Proof of Theorem 2. Suppose \gcd(M_i, m_i) > 1; then some prime p divides m_i and M_i. Since M_i is the product of the m_j with j \ne i, Euclid’s lemma gives p \mid m_j for one such j, and then p \mid \gcd(m_i, m_j) = 1, which is impossible. So y_i exists.

Fix i. For j \ne i, the factor m_i appears in M_j, so a_j M_j y_j \equiv 0 \pmod{m_i}, while a_i M_i y_i \equiv a_i \cdot 1 \pmod{m_i}. Adding, x_0 \equiv a_i \pmod{m_i}.

If x and x' are solutions, every m_i divides c = x - x'. By the lemma m_1 m_2 \mid c. The prime argument above shows \gcd(m_1 m_2, m_3) = 1, so the lemma again gives m_1 m_2 m_3 \mid c, and continuing through m_k, M \mid c. As before, anything congruent to x_0 modulo M is congruent to it modulo each m_i, so it is a solution. \square

Proof of Theorem 3. As in Theorem 1, the solutions are the x = a + mk with mk \equiv b - a \pmod{n}. By Theorem 6 of Modular inverses and linear congruences, this congruence in k has a solution if and only if \gcd(m, n) \mid b - a, which is the same as d \mid a - b.

For uniqueness, first: every common multiple c of m and n is a multiple of L. Divide, c = qL + r with 0 \le r < L. Then r = c - qL is a common multiple of m and n, and it is smaller than the least positive one, so r = 0. Now if x and x' are solutions, x - x' is a common multiple, so L \mid x - x'. Conversely x + Lt is a solution because m \mid L and n \mid L. \square

When d = 1 the lemma shows mn \mid L, and mn is itself a common multiple, so L = mn: Theorem 3 contains Theorem 1.

Proof of Theorem 4. \varphi(x) = (a, b) says exactly that x solves x \equiv a \pmod{m}, x \equiv b \pmod{n}. By Theorem 1 the solutions form one class modulo mn, with exactly one member among 0, \dots, mn - 1. So each pair has exactly one preimage. For the arithmetic: since m \mid mn, reducing x + y modulo mn first does not change its remainder modulo m; and by the addition rule of Congruence modulo n and its arithmetic, x + y \equiv (x \bmod m) + (y \bmod m) \pmod{m}. The same holds modulo n, and for products by the multiplication rule. \square

Worked examples

Examples 1 to 3 go with day 1, examples 4 to 7 with day 2.

Example 1

Two congruences by substitution

Solve x \equiv 6 \pmod{11}, x \equiv 9 \pmod{13}.

Solution

Since 11 and 13 are distinct primes, \gcd(11, 13) = 1, and Theorem 1 promises one solution modulo 143. The first congruence says x = 6 + 11k. Substituting into the second,

\begin{aligned} 6 + 11k &\equiv 9 \pmod{13}, \\ 11k &\equiv 3 \pmod{13}. \end{aligned}

Since 11 \cdot 6 = 66 = 5 \cdot 13 + 1, the inverse of 11 modulo 13 is 6, and k \equiv 6 \cdot 3 = 18 \equiv 5 \pmod{13}. Then x = 6 + 11 \cdot 5 = 61, and every solution is x \equiv 61 \pmod{143}. Check: 61 = 5 \cdot 11 + 6 and 61 = 4 \cdot 13 + 9.

Example 2

Three congruences by the formula

Solve x \equiv 2 \pmod{5}, x \equiv 3 \pmod{7}, x \equiv 4 \pmod{9}.

Solution

The moduli are pairwise coprime (9 = 3^2 shares no prime with 5 or 7), so Theorem 2 applies with M = 315 and

M_1 = 63, \quad M_2 = 45, \quad M_3 = 35.

Reduce first. 63 \equiv 3 \pmod{5} and 3 \cdot 2 = 6 \equiv 1, so y_1 = 2. 45 \equiv 3 \pmod{7} and 3 \cdot 5 = 15 \equiv 1, so y_2 = 5. 35 \equiv -1 \pmod{9}, which is its own inverse, so y_3 = -1 \equiv 8. Then

\begin{aligned} x_0 &= 2 \cdot 63 \cdot 2 + 3 \cdot 45 \cdot 5 + 4 \cdot 35 \cdot 8 \\ &= 252 + 675 + 1{,}120 = 2{,}047. \end{aligned}

Since 2{,}047 = 6 \cdot 315 + 157, the solutions are x \equiv 157 \pmod{315}. Check: 157 = 31 \cdot 5 + 2 = 22 \cdot 7 + 3 = 17 \cdot 9 + 4. As uniqueness requires, 157 \equiv 17 \pmod{35}, the value the Intuition found for the first two.

Example 3

When two schedules meet

Days are numbered from today, day 0. The street sweeper comes down Pavlina’s block every 8 days, next on day 3. The blood drive at her community center runs every 15 days, next on day 10. On which days do both happen?

Solution

A day x has the sweeper when x \equiv 3 \pmod{8} and the blood drive when x \equiv 10 \pmod{15}. Since 8 = 2^3 and 15 = 3 \cdot 5 share no prime, Theorem 1 gives one class modulo 120. Write x = 3 + 8k; then 8k \equiv 7 \pmod{15}. Since 8 \cdot 2 = 16 \equiv 1 \pmod{15}, k \equiv 14 \pmod{15}, and x = 3 + 8 \cdot 14 = 115.

Both happen on days 115, 235, 355, \dots, every 120 days. Check: 115 = 14 \cdot 8 + 3 = 7 \cdot 15 + 10.

Example 4

Moduli with a common factor

Solve x \equiv 1 \pmod{4}, x \equiv 3 \pmod{6}, and show that x \equiv 1 \pmod{4}, x \equiv 2 \pmod{6} has no solution.

Solution

Here d = \gcd(4, 6) = 2 and L = 12. For the first system 1 - 3 = -2 and 2 \mid -2, so by Theorem 3 there is one class modulo 12. With x = 1 + 4k the second congruence becomes 4k \equiv 2 \pmod{6}. Dividing 4, 2 and the modulus by 2 (Theorem 6 of Modular inverses and linear congruences) gives 2k \equiv 1 \pmod{3}, so k \equiv 2 \pmod{3} and x = 9. The solutions are x \equiv 9 \pmod{12}; in the figure, 9 sits in row 1, column 3.

For the second system 1 - 2 = -1 and 2 \nmid -1, so there is no solution. Directly: x \equiv 1 \pmod{4} makes x odd and x \equiv 2 \pmod{6} makes it even. Row 1, column 2 of the figure is empty.

Example 5

Multiplying through the factors

Find the remainder of 123 \cdot 456 on division by 35 without multiplying out.

Solution

By Theorem 4 it is enough to know the product modulo 5 and modulo 7, and each factor may be reduced first. Modulo 5: 123 \equiv 3 and 456 \equiv 1, so the product is \equiv 3. Modulo 7: 123 = 119 + 4 \equiv 4 and 456 = 455 + 1 \equiv 1, so it is \equiv 4.

Now solve x \equiv 3 \pmod{5}, x \equiv 4 \pmod{7}: the numbers 4, 11, 18 are 4 modulo 7, and 18 \equiv 3 \pmod{5}. So 123 \cdot 456 \equiv 18 \pmod{35}. Check: 123 \cdot 456 = 56{,}088 and 56{,}088 - 18 = 56{,}070 = 1{,}602 \cdot 35.

Example 6

Four square roots of 1

Find every x in \mathbb{Z}_{35} with x^2 \equiv 1 \pmod{35}.

Solution

By the lemma and its converse (5 and 7 divide anything 35 divides), 35 \mid x^2 - 1 exactly when 5 \mid x^2 - 1 and 7 \mid x^2 - 1. Modulo a prime p, p \mid (x - 1)(x + 1) forces p \mid x - 1 or p \mid x + 1 by Euclid’s lemma, so x \equiv \pm 1. That gives two choices modulo 5 and two modulo 7, and by Theorem 4 each of the 2 \cdot 2 = 4 pairs is one x modulo 35:

x \bmod 5x \bmod 7x
111
166
4129
4634

The middle rows come from listing numbers that are 6 (or 1) modulo 7 until one has the right remainder modulo 5. Check: 6^2 = 36 = 35 + 1 and 29^2 = 841 = 24 \cdot 35 + 1. So x^2 \equiv 1 \pmod{35} has four solutions, 1, 6, 29, 34, though modulo each prime it has two.

Example 7

Three moduli that share factors

Solve x \equiv 3 \pmod{10}, x \equiv 8 \pmod{15}, x \equiv 5 \pmod{12}.

Solution

No two moduli are coprime, so combine two at a time with Theorem 3. For 10 and 15: d = 5 and 5 \mid 3 - 8. With x = 3 + 10k, 10k \equiv 5 \pmod{15}; dividing by 5, 2k \equiv 1 \pmod{3}, so k \equiv 2 and, by Theorem 3, the pair is equivalent to x \equiv 23 \pmod{30}.

Now combine x \equiv 23 \pmod{30} with x \equiv 5 \pmod{12}: d = 6 and 6 \mid 23 - 5 = 18. With x = 23 + 30j, reduce modulo 12: 11 + 6j \equiv 5, so 6j \equiv 6 \pmod{12}; dividing by 6, j \equiv 1 \pmod{2}, and x = 53. The solutions are x \equiv 53 \pmod{60}, where 60 = \operatorname{lcm}(10, 15, 12). Check: 53 = 5 \cdot 10 + 3 = 3 \cdot 15 + 8 = 4 \cdot 12 + 5.

Boundaries

  • Coprime means pairwise. The moduli 6, 10, 15 have no prime common to all three, yet x \equiv 0 \pmod{6}, x \equiv 1 \pmod{10} has no solution: the first makes x even, the second odd. Theorem 2 needs every pair coprime.
  • Without coprimality, uniqueness is only modulo the lcm. x \equiv 1 \pmod{4}, x \equiv 3 \pmod{6} has the solutions 9 and 21, which differ modulo 24; and \varphi from \mathbb{Z}_{24} to \mathbb{Z}_4 \times \mathbb{Z}_6 is neither one-to-one nor onto.
  • The theorem takes congruences of the form x \equiv a. A congruence such as 3x \equiv 2 \pmod{8} must first be solved for x (Modular inverses and linear congruences).

Where this goes next

Theorem 4 says arithmetic modulo mn is arithmetic modulo m and modulo n side by side, so a large modulus can be handled in small numbers, as in Example 5. In RSA public-key encryption the modulus is a product of two primes, and decryption is often sped up this way, with powers worked out modulo each prime by Powers modulo n. Counts multiply too, as in Example 6 and Exercise 21.

Exercises

Day 1: solving systems

  1. Solve x \equiv 3 \pmod{8}, x \equiv 6 \pmod{11}.
  2. Solve x \equiv 4 \pmod{7}, x \equiv 10 \pmod{12}.
  3. Use the formula of Theorem 2 to solve x \equiv 3 \pmod{4}, x \equiv 1 \pmod{5}, x \equiv 6 \pmod{7}.
  4. Solve x \equiv 5 \pmod{6}, x \equiv 4 \pmod{5}, x \equiv 2 \pmod{13}. (Notice what the first two say about x + 1.)
  5. Find e_1 with e_1 \equiv 1 \pmod{9}, e_1 \equiv 0 \pmod{10}, and e_2 with e_2 \equiv 0 \pmod{9}, e_2 \equiv 1 \pmod{10}. Use them to solve x \equiv 7 \pmod{9}, x \equiv 4 \pmod{10}.
  6. Pavlina has a day off every 14 days, next on day 6. A blood drive runs every 9 days, next on day 4. On which days is there a blood drive on her day off?
  7. In Example 3, day 0 is a Tuesday. Number the weekdays so that Saturday is day 4 modulo 7. What is the first day on which the sweeper and the blood drive both come on a Saturday, and how often does that happen?

Day 1: reasoning

  1. Let \gcd(m, n) = 1. Without computing, give every solution of x \equiv a \pmod{m}, x \equiv a \pmod{n}, and justify it.
  2. Let \gcd(m, n) = 1. Prove that any mn consecutive integers contain exactly one solution of x \equiv a \pmod{m}, x \equiv b \pmod{n}.
  3. Explain why x \equiv 1 \pmod{6}, x \equiv 3 \pmod{10}, x \equiv 4 \pmod{15} has no solution, and which hypothesis of Theorem 2 fails.
  4. Let mu + nv = 1. Prove that x = anv + bmu solves x \equiv a \pmod{m}, x \equiv b \pmod{n}.

Day 2: any moduli and the correspondence

  1. Solve x \equiv 5 \pmod{8}, x \equiv 9 \pmod{12}.
  2. Show that x \equiv 5 \pmod{8}, x \equiv 11 \pmod{12} has no solution, in two ways.
  3. Solve x \equiv 7 \pmod{10}, x \equiv 13 \pmod{18}.
  4. For which b in \{0, 1, \dots, 20\} does x \equiv 4 \pmod{15}, x \equiv b \pmod{21} have a solution? Solve the case b = 10.
  5. Under \varphi : \mathbb{Z}_{20} \to \mathbb{Z}_4 \times \mathbb{Z}_5, find \varphi(7) and \varphi(13), and the x with \varphi(x) = (3, 0) and with \varphi(x) = (2, 4).
  6. Find 58 \cdot 73 \bmod 77 by working modulo 7 and modulo 11.
  7. Find every x in \mathbb{Z}_{30} with x^2 \equiv x \pmod{30}.
  8. Pavlina’s day off moves to every 12 days, next on day 5, and the blood drive to every 18 days, next on day 11. When do they coincide? What if the blood drive is next on day 8 instead?

Day 2: reasoning

  1. Let d = \gcd(m, n) > 1. Prove that \varphi : \mathbb{Z}_{mn} \to \mathbb{Z}_m \times \mathbb{Z}_n is not one-to-one, and deduce that it is not onto.
  2. Let \gcd(m, n) = 1. Prove that x is a unit modulo mn if and only if it is a unit modulo m and modulo n. Deduce how many units there are modulo 35.
  3. Fill the grid for moduli m and n by a walk: start at cell (0, 0) and at each step add 1 to both coordinates, wrapping around. Explain why for 3 and 4 the walk visits all 12 cells before returning to (0, 0), while for 4 and 6 it returns after 12 steps with 12 cells unvisited.
Answers
  1. x \equiv 83 \pmod{88}. x = 3 + 8k gives 8k \equiv 3 \pmod{11}; 8 \cdot 7 = 56 \equiv 1, so k \equiv 21 \equiv 10 and x = 83. Check: 83 = 10 \cdot 8 + 3 = 7 \cdot 11 + 6.
  2. x \equiv 46 \pmod{84}. x = 4 + 7k gives 7k \equiv 6 \pmod{12}; 7 \cdot 7 = 49 \equiv 1, so k \equiv 42 \equiv 6 and x = 46. Check: 46 = 6 \cdot 7 + 4 = 3 \cdot 12 + 10.
  3. x \equiv 111 \pmod{140}. M_1 = 35 \equiv 3 \pmod{4}, y_1 = 3; M_2 = 28 \equiv 3 \pmod{5}, y_2 = 2; M_3 = 20 \equiv 6 \pmod{7}, y_3 = 6. Then x_0 = 3 \cdot 35 \cdot 3 + 28 \cdot 2 + 6 \cdot 20 \cdot 6, which is 315 + 56 + 720 = 1{,}091, and 1{,}091 = 7 \cdot 140 + 111.
  4. x \equiv 119 \pmod{390}. The first two say x \equiv -1 modulo 6 and 5, so x \equiv -1 \equiv 29 \pmod{30} by Theorem 1. Then 29 + 30j \equiv 2 \pmod{13} gives 3 + 4j \equiv 2, 4j \equiv 12, j \equiv 3, and x = 119. Check: 119 = 9 \cdot 13 + 2.
  5. e_1 = 10, e_2 = 81, x \equiv 34 \pmod{90}. 10 \equiv 1 \pmod{9}, and 81 = 9^2 ends in 1. Then x = 7e_1 + 4e_2 = 394, and 394 \equiv 34 \pmod{90}.
  6. Days 76, 202, 328, \dots, every 126 days. x \equiv 6 \pmod{14}, x \equiv 4 \pmod{9}: x = 4 + 9k, 9k \equiv 2 \pmod{14}, 9 \cdot 11 = 99 \equiv 1, so k \equiv 22 \equiv 8 and x = 76 = 5 \cdot 14 + 6.
  7. Day 235, then every 840 days. Both come on days x \equiv 115 \pmod{120}; Saturday is x \equiv 4 \pmod{7}. With x = 115 + 120j and 115 \equiv 3, 120 \equiv 1 \pmod{7}: 3 + j \equiv 4, j \equiv 1, x = 235 = 33 \cdot 7 + 4. Since \gcd(120, 7) = 1, the period is 840.
  8. x \equiv a \pmod{mn}. The integer a is a solution, and by Theorem 1 the solutions are exactly the integers congruent to one solution modulo mn.
  9. Proof. By Theorem 1 the solutions are one class modulo mn. Two of c, c + 1, \dots, c + mn - 1 differ by less than mn, so at most one lies in the class; and their remainders modulo mn are all mn remainders, so one does. \square
  10. Reduced modulo 5, the second gives x \equiv 3 and the third x \equiv 4. Theorem 2 needs the moduli pairwise coprime, and \gcd(10, 15) = 5 (also \gcd(6, 10) = 2, \gcd(6, 15) = 3), though no prime divides all three.
  11. Proof. Since nv = 1 - mu \equiv 1 \pmod{m} and bmu \equiv 0 \pmod{m}, x \equiv a \cdot 1 + 0 = a \pmod{m}. Likewise mu = 1 - nv \equiv 1 \pmod{n} and anv \equiv 0 \pmod{n}, so x \equiv b \pmod{n}. \square
  12. x \equiv 21 \pmod{24}. d = 4 \mid 5 - 9. x = 5 + 8k: 8k \equiv 4 \pmod{12}, so 2k \equiv 1 \pmod{3}, k \equiv 2, x = 21. Check: 21 = 2 \cdot 8 + 5 = 12 + 9.
  13. First, \gcd(8, 12) = 4 and 4 \nmid 5 - 11 = -6, so Theorem 3 gives none. Second, directly: x \equiv 5 \pmod{8} gives x \equiv 1 \pmod{4}, and x \equiv 11 \pmod{12} gives x \equiv 3 \pmod{4}.
  14. x \equiv 67 \pmod{90}. d = 2 \mid 7 - 13, L = 90. x = 7 + 10k: 10k \equiv 6 \pmod{18}, so 5k \equiv 3 \pmod{9}; 5 \cdot 2 = 10 \equiv 1, so k \equiv 6 and x = 67 = 3 \cdot 18 + 13.
  15. b = 1, 4, 7, 10, 13, 16, 19; for b = 10, x \equiv 94 \pmod{105}. \gcd(15, 21) = 3 must divide 4 - b, so b \equiv 1 \pmod{3}. For b = 10: x = 4 + 15k, 15k \equiv 6 \pmod{21}, 5k \equiv 2 \pmod{7}, k \equiv 3 \cdot 2 = 6, x = 94 = 4 \cdot 21 + 10.
  16. \varphi(7) = (3, 2), \varphi(13) = (1, 3); (3, 0) comes from 15 and (2, 4) from 14. Among the multiples of 5 below 20, only 15 \equiv 3 \pmod{4}; among 4, 9, 14, 19, only 14 \equiv 2 \pmod{4}.
  17. 76. Modulo 7: 58 \equiv 2, 73 \equiv 3, product \equiv 6 \equiv -1. Modulo 11: 58 \equiv 3, 73 \equiv 7, product 21 \equiv 10 \equiv -1. So the product is \equiv -1 \equiv 76 \pmod{77}. Check: 58 \cdot 73 = 4{,}234 = 55 \cdot 77 - 1.
  18. x = 0, 1, 6, 10, 15, 16, 21, 25. Since 30 = 2 \cdot 3 \cdot 5, the condition holds modulo 30 exactly when it holds modulo each prime, and p \mid x(x - 1) means x \equiv 0 or 1 \pmod{p}. The 2^3 = 8 choices give one x each by Theorem 2; for example (0, 0, 1) gives 6 and (1, 0, 0) gives 15.
  19. Days 29, 65, 101, \dots, every 36 days; with day 8, never. x \equiv 5 \pmod{12}, x \equiv 11 \pmod{18}: d = 6 \mid -6, and x = 5 + 12k, 12k \equiv 6 \pmod{18}, 2k \equiv 1 \pmod{3}, k \equiv 2, x = 29 = 18 + 11. With x \equiv 8 \pmod{18}, 6 \nmid 5 - 8 = -3.
  20. Proof. Let c = mn/d = m \cdot \tfrac{n}{d} = n \cdot \tfrac{m}{d}. It is a common multiple of m and n, and 0 < c < mn since d > 1. So \varphi(c) = (0, 0) = \varphi(0) with c \ne 0 in \mathbb{Z}_{mn}, and \varphi is not one-to-one. Both sets have mn elements, so the image of \varphi has fewer than mn elements, and some pair is missed. \square
  21. Proof. By Theorem 1 of Modular inverses and linear congruences, x is a unit modulo k exactly when \gcd(x, k) = 1. If a prime divides x and mn, Euclid’s lemma puts it in m or n; conversely a prime dividing x and m (or n) divides mn. So \gcd(x, mn) = 1 if and only if \gcd(x, m) = 1 and \gcd(x, n) = 1. \square Modulo 5 there are 4 units and modulo 7 there are 6; by Theorem 4 the units modulo 35 correspond to pairs, so there are 4 \cdot 6 = 24.
  22. After t steps the walk is at \varphi(t) = (t \bmod m, t \bmod n). It is first back at (0, 0) when m \mid t and n \mid t, at t = \operatorname{lcm}(m, n), and before that no cell repeats, since a repeat at steps s < t would put (0, 0) at step t - s. For 3 and 4 the lcm is 12, every cell; for 4 and 6 it is 12 of the 24.
kg1128 · updated 2026-10-22 · CC-BY-SA-4.0