ChineseRemainder[{r1,r2,…},{m1,m2,…}]
gives the smallest
with
that satisfies all the integer congruences
.
ChineseRemainder[{r1,r2,…},{m1,m2,…},d]
gives the smallest
with
that satisfies all the integer congruences
.
ChineseRemainder
ChineseRemainder[{r1,r2,…},{m1,m2,…}]
gives the smallest
with
that satisfies all the integer congruences
.
ChineseRemainder[{r1,r2,…},{m1,m2,…},d]
gives the smallest
with
that satisfies all the integer congruences
.
Details
- If no solution for
exists, ChineseRemainder returns unevaluated. » - If all 0≤ri<mi, then the result satisfies
. - ChineseRemainder[{r1,r2,…},{m1,m2,…}] gives a solution
with
. » - ChineseRemainder[{r1,r2,…},{m1,m2,…},d] gives a solution
with
. »
Examples
open all close allBasic Examples (2)
Scope (1)
Applications (3)
Database encryption and decryption:
data = {931074546, 117172357, 482333642, 199386034, 394354985}keys = RandomPrime[{10 ^ 9, 10 ^ 12}, 5]encrypted = ChineseRemainder[data, keys]Mod[encrypted, keys]Define a residue number system:
m = {Prime[100], Prime[101], Prime[102], Prime[103]};Numbers and their representation in a residue system:
n1 = 123456787;
n2 = 123;n1r = Mod[n1, m]n2r = Mod[n2, m]Multiplying and recovering in the residue system:
ChineseRemainder[n1r n2r, m]n1 n2ChineseRemainder[n1r + n2r, m]n1 + n2Modular computation of a determinant:
a = {{12, 13}, {14, 15}};d1 = Det[a, Modulus -> 5]d2 = Det[a, Modulus -> 7]ChineseRemainder[{d1, d2}, {5, 7}]Shift residue to be symmetric:
Mod[33, 5 7, (-5 7 + 1) / 2]Det[a]Properties & Relations (4)
ChineseRemainder[{r1,r2,…},{r1,r2,…}] yields zero:
ChineseRemainder[{2, 3, 4}, {2, 3, 4}]A solution need not exist, in which case ChineseRemainder returns unevaluated:
ChineseRemainder[{2, 8, 9, 10, 2}, {7, 8, 3, 4, 10}]ChineseRemainder[{2, 8, 9, 10, 2}, {7, 8, 3, 4, 10}, 3]If ChineseRemainder[{r1,r2,…},{m1,m2,…}] yields a solution n, then
:
DeleteCases[Table[{remainders, mods} = RandomInteger[{1, 10}, {2, 5}];
0 <= ChineseRemainder[remainders, mods] <= LCM@@mods, {1000}], _LessEqual]//UnionChineseRemainder[{r1,r2,…},{m1,m2,…},d] yields solutions with
:
DeleteCases[Table[{remainders, mods} = RandomInteger[{1, 10}, {2, 5}];
100 <= ChineseRemainder[remainders, mods, 100] <= LCM@@mods + 100, {1000}], _LessEqual]//Quiet//UnionSolve congruential equations using Reduce or FindInstance:
Reduce[{Mod[x, 3] == 1, Mod[x, 5] == 2}, x, Integers]FindInstance[{Mod[x, 3] == 1, Mod[x, 5] == 2}, x, Integers]ChineseRemainder[{1, 2}, {3, 5}]See Also
Function Repository: IntegerSpectralDecomposition IntegerSpectralBasis
Tech Notes
Related Guides
Text
Wolfram Research (2007), ChineseRemainder, Wolfram Language function, https://reference.wolfram.com/language/ref/ChineseRemainder.html (updated 2016).
CMS
Wolfram Language. 2007. "ChineseRemainder." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/ChineseRemainder.html.
APA
Wolfram Language. (2007). ChineseRemainder. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ChineseRemainder.html
BibTeX
@misc{reference.wolfram_2026_chineseremainder, author="Wolfram Research", title="{ChineseRemainder}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/ChineseRemainder.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_chineseremainder, organization={Wolfram Research}, title={ChineseRemainder}, year={2016}, url={https://reference.wolfram.com/language/ref/ChineseRemainder.html}, note=[Accessed: 13-June-2026]}