{
  "id": "chinese-remainder-theorem",
  "title": "Chinese Remainder Theorem",
  "lang": "en",
  "source_lang": "en",
  "summary": "The Chinese remainder theorem characterizes when simultaneous integer congruences have a solution and how that solution is uniquely determined modulo a common modulus.",
  "category": "mathematics",
  "subcategory": "algebra",
  "type": "concept",
  "aliases": [
    "CRT",
    "Chinese remainder theorem"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/chinese-remainder-theorem/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/chinese-remainder-theorem/",
      "json": "https://aiwiki.page/zh/chinese-remainder-theorem.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The Chinese remainder theorem is a theorem in number theory stating that congruences with pairwise coprime positive integer moduli can be solved simultaneously, with a unique solution modulo the product of those moduli. It provides both a way to reconstruct an integer from its remainders and a structural description of modular arithmetic: computation modulo a product of coprime numbers is equivalent to independent computation modulo each factor. Generalized forms cover noncoprime moduli, polynomials, and ideals in commutative rings."
    },
    {
      "heading": "Statement",
      "text": "Let \\(m_1,\\ldots,m_r\\) be integers greater than \\(1\\), and suppose they are pairwise coprime:\n\n\\[\\gcd(m_i,m_j)=1\\qquad\\text{whenever }i\\ne j,\\]\n\nwhere \\(\\gcd\\) denotes the greatest common divisor. For any integers \\(a_1,\\ldots,a_r\\), the simultaneous congruences\n\n\\[x\\equiv a_i\\pmod{m_i}, \\qquad i=1,\\ldots,r,\\]\n\nhave a solution. If\n\n\\[M=m_1m_2\\cdots m_r,\\]\n\nthen any two solutions differ by a multiple of \\(M\\). Equivalently, there is exactly one solution in the range \\(0\\le x<M\\), and all integer solutions have the form\n\n\\[x=x_0+kM,\\qquad k\\in\\mathbb Z.\\]\n\nThe condition is pairwise coprimality, not merely that the greatest common divisor of all the moduli is \\(1\\). For example, \\(6,10,15\\) have collective greatest common divisor \\(1\\), but no two are coprime.\n\nUniqueness is therefore uniqueness modulo \\(M\\), not uniqueness as an unrestricted integer."
    },
    {
      "heading": "Constructive formula and proof",
      "text": "Set\n\n\\[M_i=\\frac{M}{m_i}.\\]\n\nSince the moduli are pairwise coprime, \\(\\gcd(M_i,m_i)=1\\). Consequently, \\(M_i\\) has a multiplicative inverse modulo \\(m_i\\): there is an integer \\(u_i\\) such that\n\n\\[M_i u_i\\equiv 1\\pmod{m_i}.\\]\n\nThese inverses can be computed using the extended Euclidean algorithm. Their existence also follows from Bézout's identity, which expresses the greatest common divisor of two integers as an integer linear combination of them.\n\nA solution is\n\n\\[x\\equiv\\sum_{i=1}^{r}a_iM_i u_i\\pmod M.\\]\n\nTo verify existence, consider the sum modulo a particular \\(m_j\\). Every term with \\(i\\ne j\\) vanishes because \\(m_j\\) divides \\(M_i\\). The remaining term satisfies\n\n\\[a_jM_j u_j\\equiv a_j\\pmod{m_j}.\\]\n\nThus the sum satisfies every congruence.\n\nFor uniqueness, let \\(x\\) and \\(y\\) be solutions. Each \\(m_i\\) divides \\(x-y\\). Because the moduli are pairwise coprime, their product \\(M\\) also divides \\(x-y\\), so\n\n\\[x\\equiv y\\pmod M.\\]\n\nThis gives a constructive proof: it both establishes the theorem and supplies an algorithm for finding the solution."
    },
    {
      "heading": "Classical example",
      "text": "Consider\n\n\\[\\begin{aligned} x&\\equiv2\\pmod3,\\\\ x&\\equiv3\\pmod5,\\\\ x&\\equiv2\\pmod7. \\end{aligned}\\]\n\nHere \\(M=105\\), and\n\n\\[M_1=35,\\qquad M_2=21,\\qquad M_3=15.\\]\n\nSuitable inverses are \\(u_1=2\\), \\(u_2=1\\), and \\(u_3=1\\), since\n\n\\[35\\cdot2\\equiv1\\pmod3,\\qquad 21\\equiv1\\pmod5,\\qquad 15\\equiv1\\pmod7.\\]\n\nThe reconstruction formula gives\n\n\\[x\\equiv2(35)(2)+3(21)+2(15) =233 \\equiv23\\pmod{105}.\\]\n\nHence the least nonnegative solution is \\(23\\), and the complete set of solutions is\n\n\\[x=23+105k,\\qquad k\\in\\mathbb Z.\\]\n\nThe residues do not distinguish \\(23\\) from \\(128\\), \\(-82\\), or any other integer in this residue class. A bound or a prescribed interval is needed to identify one particular integer."
    },
    {
      "heading": "Noncoprime moduli",
      "text": "Pairwise coprimality guarantees a solution for every choice of remainders. Without it, existence depends on compatibility.\n\nFor arbitrary positive integer moduli \\(m_1,\\ldots,m_r\\), the system\n\n\\[x\\equiv a_i\\pmod{m_i}\\]\n\nhas a solution if and only if\n\n\\[a_i\\equiv a_j\\pmod{\\gcd(m_i,m_j)}\\]\n\nfor every pair \\(i,j\\). Whenever a solution exists, it is unique modulo\n\n\\[L=\\operatorname{lcm}(m_1,\\ldots,m_r),\\]\n\nwhere \\(\\operatorname{lcm}\\) is the least common multiple.\n\nThe necessity follows because a common divisor of \\(m_i\\) and \\(m_j\\) must divide \\(a_i-a_j\\). Sufficiency can be proved by merging congruences successively.\n\nFor two congruences,\n\n\\[x\\equiv a\\pmod m,\\qquad x\\equiv b\\pmod n,\\]\n\nwrite \\(x=a+mt\\). The second congruence becomes\n\n\\[mt\\equiv b-a\\pmod n.\\]\n\nWith \\(d=\\gcd(m,n)\\), this is solvable exactly when \\(d\\mid(b-a)\\). Dividing by \\(d\\) then gives\n\n\\[\\frac{m}{d}t\\equiv\\frac{b-a}{d}\\pmod{n/d},\\]\n\nwhose coefficient \\(m/d\\) is invertible modulo \\(n/d\\). The merged solution is determined modulo \\(mn/d\\).\n\nFor example,\n\n\\[x\\equiv1\\pmod4,\\qquad x\\equiv3\\pmod6\\]\n\nis compatible because both remainders are odd. Its solution is\n\n\\[x\\equiv9\\pmod{12}.\\]\n\nBy contrast, replacing the second remainder with \\(2\\) makes the system inconsistent: it would require \\(x\\) to be both odd and even."
    },
    {
      "heading": "Algebraic interpretation",
      "text": "The theorem can be expressed as an isomorphism of rings:\n\n\\[\\mathbb Z/M\\mathbb Z \\cong \\prod_{i=1}^{r}\\mathbb Z/m_i\\mathbb Z.\\]\n\nHere \\(\\mathbb Z/n\\mathbb Z\\) is the ring of integer residue classes modulo \\(n\\), and the product on the right uses coordinatewise addition and multiplication.\n\nThe map\n\n\\[[x]_M\\longmapsto ([x]_{m_1},\\ldots,[x]_{m_r})\\]\n\nis a ring homomorphism. The theorem establishes that it is bijective: every tuple of residues is represented, and each has exactly one preimage modulo \\(M\\).\n\nThis formulation explains why reconstruction is compatible with arithmetic. Integers can be added or multiplied separately in the smaller modular rings, and the reconstructed result agrees with addition or multiplication modulo \\(M\\).\n\nThe elements\n\n\\[e_i=M_i u_i\\pmod M\\]\n\nused in the constructive proof satisfy\n\n\\[e_i^2=e_i,\\qquad e_ie_j=0\\quad(i\\ne j),\\qquad \\sum_{i=1}^{r}e_i=1.\\]\n\nThey are mutually orthogonal instances of idempotence and serve as selectors for the product's coordinates.\n\nGeneralization to ideals\n\nLet \\(R\\) be a commutative ring with identity, and let \\(I_1,\\ldots,I_r\\) be ideals that are pairwise comaximal, meaning\n\n\\[I_i+I_j=R\\qquad(i\\ne j).\\]\n\nThen\n\n\\[R\\Big/\\bigcap_{i=1}^{r}I_i \\cong \\prod_{i=1}^{r}R/I_i.\\]\n\nFor finitely many pairwise comaximal ideals,\n\n\\[\\bigcap_{i=1}^{r}I_i=I_1I_2\\cdots I_r.\\]\n\nThe integer theorem is the case \\(R=\\mathbb Z\\) and \\(I_i=m_i\\mathbb Z\\). Unlike integers, ideals in an arbitrary commutative ring need not satisfy a sufficient compatibility criterion based solely on pairwise agreement; the comaximal hypothesis is central to this product decomposition."
    },
    {
      "heading": "Polynomial version",
      "text": "Let \\(F\\) be a field, and let \\(f_1,\\ldots,f_r\\) be pairwise coprime nonconstant polynomials in \\(F[t]\\). Given arbitrary polynomials \\(a_i\\), there is a polynomial \\(g\\) satisfying\n\n\\[g\\equiv a_i\\pmod{f_i}\\]\n\nfor every \\(i\\), uniquely modulo \\(f_1\\cdots f_r\\). It therefore has a unique representative of degree less than\n\n\\[\\deg(f_1\\cdots f_r).\\]\n\nTaking \\(f_i(t)=t-\\alpha_i\\) for distinct elements \\(\\alpha_i\\in F\\) turns the congruences into prescribed values,\n\n\\[g(\\alpha_i)=a_i.\\]\n\nThe polynomial remainder theorem thus connects the Chinese remainder theorem with polynomial interpolation, including the Lagrange interpolation formula. Powers \\((t-\\alpha_i)^{k_i}\\) similarly encode higher-order local polynomial data."
    },
    {
      "heading": "Historical development",
      "text": "The theorem takes its name from an early Chinese remainder problem recorded in the Sunzi Suanjing (Mathematical Classic of Master Sun), whose precise date of composition is uncertain. The problem asks for a number that leaves remainders \\(2\\), \\(3\\), and \\(2\\) when divided by \\(3\\), \\(5\\), and \\(7\\), respectively. Its least positive solution is \\(23\\).\n\nIn 1247, Qin Jiushao's Shushu Jiuzhang (Mathematical Treatise in Nine Sections) presented more general methods for remainder problems, including procedures for finding the modular inverses needed in reconstruction. The familiar modern theorem abstracts these computational methods into a statement about arbitrary finite systems of congruences. Its formulation through ideals and quotient rings belongs to the later development of abstract algebra."
    },
    {
      "heading": "Algorithms and applications",
      "text": "Exact computation\n\nThe theorem supports computations with large integers by replacing one large calculation with several calculations modulo smaller, pairwise coprime numbers. The modular computations can often be performed independently, making the method suitable for parallel computing.\n\nIf an integer result is known to lie in an interval containing fewer than \\(M\\) consecutive integers, its residues modulo factors with product \\(M\\) determine it uniquely within that interval. For example, a bound \\(|x|\\le B\\) permits unique signed reconstruction when \\(M>2B\\).\n\nThis principle is used in exact polynomial arithmetic, determinant computation, and other symbolic algorithms. Modular reconstruction gives a residue class; a proven size bound or another verification step is needed to identify the intended unrestricted integer.\n\nCryptography\n\nIn the RSA cryptosystem, a private-key operation modulo \\(N=pq\\), with distinct primes \\(p\\) and \\(q\\), can be performed separately modulo \\(p\\) and modulo \\(q\\), followed by Chinese remainder reconstruction. The smaller modular exponentiations usually make this faster than a direct computation modulo \\(N\\).\n\nThis acceleration requires implementation safeguards. A faulty result that is correct modulo one prime but not the other can, under suitable conditions, reveal a factor of \\(N\\). The theorem supplies the arithmetic decomposition, not protection against implementation faults.\n\nSolving modular equations\n\nWhen a modulus has a factorization into coprime prime powers,\n\n\\[N=p_1^{k_1}\\cdots p_s^{k_s},\\]\n\na polynomial congruence modulo \\(N\\) can be solved separately modulo each prime power. Every compatible choice of local roots then reconstructs to exactly one root modulo \\(N\\). Consequently, the number of roots modulo \\(N\\) is the product of the numbers of roots modulo the prime-power factors.\n\nComputational limitations\n\nThe theorem does not itself find a useful factorization of a large modulus. Efficient arithmetic modulo its factors presupposes that those factors are already available.\n\nNor does it make exact reconstruction insensitive to error: changing even one remainder can produce a very different reconstructed integer. Error-tolerant reconstruction requires additional assumptions, redundancy, or specialized methods beyond the basic theorem."
    }
  ],
  "links": [
    "number-theory",
    "integer",
    "modular-arithmetic",
    "greatest-common-divisor",
    "euclidean-algorithm",
    "bezouts-identity",
    "mathematical-proof",
    "least-common-multiple",
    "isomorphism",
    "ring-mathematics",
    "homomorphism",
    "idempotence",
    "ideal-ring-theory",
    "field-mathematics",
    "polynomial",
    "interpolation",
    "abstract-algebra",
    "parallel-computing",
    "determinant",
    "rsa-cryptosystem"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}