Coprimality is the hypothesis
Without it the system may be inconsistent (x ≡ 1 mod 4 and x ≡ 2 mod 6) or have several solutions.
Given remainders modulo pairwise coprime numbers, there is exactly one integer modulo their product with those remainders. It is constructive, and it is why RSA implementations run about four times faster than the naive method.
Core ideas
A number is determined by its remainders, provided the moduli share no factors.
Without it the system may be inconsistent (x ≡ 1 mod 4 and x ≡ 2 mod 6) or have several solutions.
Each term contributes the right remainder to its own modulus and 0 to the others, so the sum has all the required remainders at once.
Working modulo pq is equivalent to working modulo p and modulo q separately, which is a real speed-up when p and q are large.
The material
Statement, construction, proof, and the application to RSA.
Let m₁, …, m_k be pairwise coprime positive integers and M = m₁⋯m_k. For any a₁, …, a_k the system x ≡ aᵢ (mod mᵢ) has exactly one solution modulo M.
Construction. Let Mᵢ = M/mᵢ. Since the moduli are pairwise coprime, gcd(Mᵢ, mᵢ) = 1, so Mᵢ has an inverse yᵢ modulo mᵢ. Set x = Σ aᵢ Mᵢ yᵢ.
Modulo mⱼ, every term with i ≠ j vanishes because mⱼ | Mᵢ. The remaining term is aⱼ Mⱼ yⱼ ≡ aⱼ · 1 = aⱼ. So x satisfies every congruence.
Uniqueness. If x and x' both solve the system, then mᵢ | (x − x') for every i. Pairwise coprimality gives M | (x − x'), so x ≡ x' (mod M).
□
The construction is the theorem's real content. Each term is built to be invisible to every modulus but its own, so the terms do not interfere and the sum can satisfy all the congruences simultaneously.
"There are things whose number is unknown. Divided by 3 the remainder is 2; by 5 the remainder is 3; by 7 the remainder is 2." With M = 105: M₁ = 35, y₁ = 2; M₂ = 21, y₂ = 1; M₃ = 15, y₃ = 1. So x = 2·35·2 + 3·21·1 + 2·15·1 = 140 + 63 + 30 = 233 ≡ 23 (mod 105). Check: 23 = 7·3 + 2, 23 = 4·5 + 3, 23 = 3·7 + 2. The problem is from a Chinese text of the third century.
x ≡ 1 (mod 4) and x ≡ 2 (mod 6) has no solution: the first makes x odd and the second makes it even. gcd(4,6) = 2 and the remainders disagree modulo 2.
x ≡ 1 (mod 4) and x ≡ 3 (mod 6) has solutions x ≡ 9 (mod 12), not modulo 24. The correct modulus for non-coprime systems is the lcm, and consistency requires the remainders to agree modulo every pairwise gcd.
Decryption computes c^d mod n with n = pq. By the theorem, that is equivalent to computing c^d mod p and c^d mod q and recombining. The two exponentiations use numbers half the size, and modular multiplication costs roughly the square of the operand size — so each is about four times cheaper, and two of them together about twice.
In practice the exponents can also be reduced modulo p − 1 and q − 1 by Fermat's theorem (“Fermat's Little Theorem and Euler's Theorem”), which is where the rest of the speed-up comes from. The overall gain is roughly a factor of four, and essentially every RSA implementation does this.
Interactive
Algorithms with their traces
Method
Check coprimality, then build the solution term by term.
If not, the system may be inconsistent, and if consistent the modulus of the answer is the lcm rather than the product.
Mᵢ is divisible by every modulus except the ith, which is what makes the terms independent.
By the extended algorithm. These are the yᵢ.
x = Σ aᵢMᵢyᵢ (mod M), then verify every original congruence.
x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7).
Each Mᵢ was reduced modulo its own mᵢ before inverting, which keeps the numbers small: inverting 35 modulo 3 is inverting 2 modulo 3. The solution is unique modulo 105, so 23, 128, 233 and −82 are all the same answer.
Solve x ≡ 1 (mod 5), x ≡ 2 (mod 7), x ≡ 3 (mod 9) by the construction. Searching would take up to 315 trials; the construction takes three inversions.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.