In mathematics, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer n by several integers, then one can determine uniquely the remainder of the division of n by the product of these integers, under the condition that the divisors are pairwise coprime (no two divisors share a common factor other than 1).
The theorem is sometimes called Sunzi's theorem. Both names of the theorem refer to its earliest known statement that appeared in Sunzi Suanjing, a Chinese manuscript written during the 3rd to 5th century CE. This first statement was restricted to the following example: The Chinese remainder theorem is widely used for computing with large integers, as it allows replacing a computation for which one knows a bound on the size of the result by several similar computations on small integers. The Chinese remainder theorem (expressed in terms of congruences) is true over every principal ideal domain. It has been generalized to any ring, with a formulation involving two-sided ideals.
History The earliest known statement of the problem appears in the 5th-century book Sunzi Suanjing by the Chinese mathematician Sunzi:
There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there? Sunzi's work would not be considered a theorem by modern standards; it only gives one particular problem, without showing how to solve it, much less any proof about the general case or a general algorithm for solving it. An algorithm for solving this problem was described by Aryabhata (6th century). Special cases of the Chinese remainder theorem were also known to Brahmagupta (7th century) and appear in Fibonacci's Liber Abaci (1202). The result was later generalized with a complete solution called Da-yan-shu (大衍術) in Qin Jiushao's 1247 Mathematical Treatise in Nine Sections which was translated into English in early 19th century by British missionary Alexander Wylie.
The notion of congruences was first introduced and used by Carl Friedrich Gauss in his Disquisitiones Arithmeticae of 1801. Gauss illustrates the Chinese remainder theorem on a problem involving calendars, namely, "to find the years that have a certain period number with respect to the solar and lunar cycle and the Roman indiction." Gauss introduces a procedure for solving the problem that had already been used by Leonhard Euler but was in fact an ancient method that had appeared several times.
Statement Let n1, ..., nk be integers greater than 1, which are often called moduli or divisors. Let us denote by N the product of the ni. The Chinese remainder theorem asserts that if the ni are pairwise coprime, and if a1, ..., ak are integers such that 0 ≤ ai < ni for every i, then there is one and only one integer x, such that 0 ≤ x < N and the remainder of the Euclidean division of x by ni is ai for every i. This may be restated as follows in terms of congruences: If the ni are pairwise coprime, and if a1, ..., ak are any integers, then the system
x≡a1(modn1)⋮x≡ak(modnk), has a solution, and any two solutions, say x1 and x2, are congruent modulo N, that is, x1 ≡ x2 (mod N ). In abstract algebra, the theorem is often restated as: If the ni are pairwise coprime, the map
xmodN↦(xmodn1,…,xmodnk) defines a ring isomorphism
ℤ/Nℤ≅ℤ/n1ℤ×⋯×ℤ/nkℤ between the ring of integers modulo N and the direct product of the rings of integers modulo the ni. This means that for doing a sequence of arithmetic operations in ℤ/Nℤ, one may do the same computation independently in each ℤ/niℤ and then get the result by applying the isomorphism (from the right to the left). This may be much faster than the direct computation if N and the number of operations are large. This is widely used, under the name multi-modular computation, for linear algebra over the integers or the rational numbers. The theorem can also be restated in the language of combinatorics as the fact that the infinite arithmetic progressions of integers form a Helly family.
Proof The existence and the uniqueness of the solution may be proven independently. However, the first proof of existence, given below, uses this uniqueness.
Uniqueness Suppose that x and y are both solutions to all the congruences. As x and y give the same remainder, when divided by ni, their difference x − y is a multiple of each ni. As the ni are pairwise coprime, their product N also divides x − y, and thus x and y are congruent modulo N. If x and y are supposed to be non-negative and less than N (as in the first statement of the theorem), then their difference may be a multiple of N only if x = y.
Existence (first proof) The map
xmodN↦(xmodn1,…,xmodnk) maps congruence classes modulo N to sequences of congruence classes modulo ni. The proof of uniqueness shows that this map is injective. As the domain and the codomain of this map have the same number of elements, the map is also surjective, which proves the existence of the solution. This proof is very simple but does not provide any direct way for computing a solution. Moreover, it cannot be generalized to other situations where the following proof can.
Existence (constructive proof) Existence may be established by an explicit construction of x. This construction may be split into two steps, first solving the problem in the case of two moduli, and then extending this solution to the general case by induction on the number of moduli.
Case of two moduli We want to solve the system:
x≡a1(modn1)x≡a2(modn2), where n1 and n2 are coprime. Bézout's identity asserts the existence of two integers m1 and m2 such that
m1n1+m2n2=1. The integers m1 and m2 may be computed by the extended Euclidean algorithm. A solution is given by
x=a1m2n2+a2m1n1. Indeed,
x=a1m2n2+a2m1n1=a1(1−m1n1)+a2m1n1=a1+(a2−a1)m1n1, implying that x≡a1(modn1). The second congruence is proved similarly, by exchanging the subscripts 1 and 2.
General case Consider a sequence of congruence equations:
x≡a1(modn1)⋮x≡ak(modnk), where the ni are pairwise coprime. The two first equations have a solution a1,2 provided by the method of the previous section. The set of the solutions of these two first equations is the set of all solutions of the equation
… excerpt ends here. Continue reading the full article.


![Chinese remainder theorem: The Chinese remainder theorem appears in Gauss's 1801 book Disquisitiones Arithmeticae.[9]](https://thumb.wikimedia.org/wikipedia/commons/thumb/e/e3/Disqvisitiones-800.jpg/330px-Disqvisitiones-800.jpg?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
