## You are here

HomeChinese remainder theorem

## Primary tabs

# Chinese remainder theorem

Suppose we have a set of $n$ congruences of the form

$\begin{array}[]{ccc}x&\equiv&a_{1}\;\;(\mathop{{\rm mod}}p_{1})\\ x&\equiv&a_{2}\;\;(\mathop{{\rm mod}}p_{2})\\ &\vdots&\\ x&\equiv&a_{n}\;\;(\mathop{{\rm mod}}p_{n})\\ \end{array}$ |

where $p_{1},p_{2},\dots,p_{n}$ are relatively prime. Let

$P=\prod_{{i=1}}^{n}p_{i}$ |

and, for all $i\in\mathbb{N}$ ($1\leq i\leq n$), let $y_{i}$ be an integer that satisfies

$y_{i}\cdot\frac{P}{p_{i}}\equiv 1\;\;(\mathop{{\rm mod}}p_{i})$ |

Then one solution of these congruences is

$x_{0}=\sum_{{i=1}}^{n}a_{i}y_{i}\cdot\frac{P}{p_{i}}$ |

Any $x\in\mathbb{Z}$ satisfies the set of congruences if and only if it satisfies

$x\equiv x_{0}\;\;(\mathop{{\rm mod}}P)$ |

The Chinese remainder theorem originated in the book *“Sun Zi Suan Jing”*, or Sun Tzu’s Arithmetic Classic, by the Chinese mathematician Sun Zi, or Sun Tzu, who also wrote “Sun Zi Bing Fa”, or Sun Tzu’s The Art of War. The theorem is said to have been used to count the size of the ancient Chinese armies (i.e., the soldiers would split into groups of 3, then 5, then 7, etc, and the “leftover” soldiers from each grouping would be counted).

## Mathematics Subject Classification

11D79*no label found*

- Forums
- Planetary Bugs
- HS/Secondary
- University/Tertiary
- Graduate/Advanced
- Industry/Practice
- Research Topics
- LaTeX help
- Math Comptetitions
- Math History
- Math Humor
- PlanetMath Comments
- PlanetMath System Updates and News
- PlanetMath help
- PlanetMath.ORG
- Strategic Communications Development
- The Math Pub
- Testing messages (ignore)

- Other useful stuff
- Corrections