# Welcome to ChineseRemainderTheorem.com!

Use the calculator below to get a step-by-step calculation of the Chinese Remainder Theory. Just enter the numbers you would like and press "Calculate" .

This removes all numbers from the textboxes, such that you can fill in your own.

This fills all textboxes with random numbers. If you fill in random numbers yourself, it is very likely that those numbers do not have a solution. To avoid disappointment, use this button instead! It only uses random numbers that do have a solution.

This button is similar to the "Clear everything" button, but only clears the left column.

This is useful if you want your equations to be of the form `x ≡ a (mod m)`

rather than `bx ≡ a (mod m)`

.

In that case, it can be especially useful after using the random numbers button.

Do you want to use more equations? Go ahead and use this button. It adds another row that you can fill in. Not sure what numbers to put in this newly added row? Use the random numbers button again!

Do you have too many rows? Use one of these buttons to remove a row. You can always add a row again using the yellow "Add a row" button.

Are you ready to view a full step-by-step Chinese Remainder Theorem calculation for the numbers you have entered? Then use this button!

**Want to know more?**

- Read about how to execute the Chinese Remainder Theorem
- Discover different ways to calculate multiplicative inverses

Transform the equations

You used one or more of the fields on the left, so your equations are of the form `bx ≡ a mod m`

.

We want them to be of the form `x ≡ a mod m`

, so we need to move the values on the left to the right side of the equation.

For a more detailed explanation about how this works, see this part of our page about how to execute the Chinese Remainder algorithm.

First, we calculate the inverses of the leftmost value on each row:

n | b | q | r | t1 | t2 | t3 |
---|---|---|---|---|---|---|

347 | 215 | 1 | 132 | 0 | 1 | -1 |

215 | 132 | 1 | 83 | 1 | -1 | 2 |

132 | 83 | 1 | 49 | -1 | 2 | -3 |

83 | 49 | 1 | 34 | 2 | -3 | 5 |

49 | 34 | 1 | 15 | -3 | 5 | -8 |

34 | 15 | 2 | 4 | 5 | -8 | 21 |

15 | 4 | 3 | 3 | -8 | 21 | -71 |

4 | 3 | 1 | 1 | 21 | -71 | 92 |

3 | 1 | 3 | 0 | -71 | 92 | -347 |

*Source: ExtendedEuclideanAlgorithm.com*

n | b | q | r | t1 | t2 | t3 |
---|---|---|---|---|---|---|

943 | 206 | 4 | 119 | 0 | 1 | -4 |

206 | 119 | 1 | 87 | 1 | -4 | 5 |

119 | 87 | 1 | 32 | -4 | 5 | -9 |

87 | 32 | 2 | 23 | 5 | -9 | 23 |

32 | 23 | 1 | 9 | -9 | 23 | -32 |

23 | 9 | 2 | 5 | 23 | -32 | 87 |

9 | 5 | 1 | 4 | -32 | 87 | -119 |

5 | 4 | 1 | 1 | 87 | -119 | 206 |

4 | 1 | 4 | 0 | -119 | 206 | -943 |

*Source: ExtendedEuclideanAlgorithm.com*

n | b | q | r | t1 | t2 | t3 |
---|---|---|---|---|---|---|

827 | 893 | 0 | 827 | 0 | 1 | 0 |

893 | 827 | 1 | 66 | 1 | 0 | 1 |

827 | 66 | 12 | 35 | 0 | 1 | -12 |

66 | 35 | 1 | 31 | 1 | -12 | 13 |

35 | 31 | 1 | 4 | -12 | 13 | -25 |

31 | 4 | 7 | 3 | 13 | -25 | 188 |

4 | 3 | 1 | 1 | -25 | 188 | -213 |

3 | 1 | 3 | 0 | 188 | -213 | 827 |

*Source: ExtendedEuclideanAlgorithm.com*

Click on any row to reveal a more detailed calculation of each multiplicative inverse.

Now that we now the inverses, let's move the leftmost value on each row to the right of the equation:

`x ≡ 446 × 215`

^{-1} (mod 347) ≡ 446 × 92 (mod 347) ≡ 86 (mod 347)`x ≡ 229 × 206`

^{-1} (mod 943) ≡ 229 × 206 (mod 943) ≡ 24 (mod 943)`x ≡ 192 × 893`

^{-1} (mod 827) ≡ 192 × 614 (mod 827) ≡ 454 (mod 827)

**New equations**

So now we have the following equations of the form x ≡ a (mod m):

x ≡ 86 (mod 347)

x ≡ 24 (mod 943)

x ≡ 454 (mod 827)

Now the actual calculation

**Find the common modulus M**

`M = m`

_{1}× m_{2}× ... × m_{k}= 347 × 943 × 827 = 270611767**We calculate the numbers M**_{1}to M_{3}

`M`

,_{1}=M/m_{1}=270611767/347=779861`M`

,_{2}=M/m_{2}=270611767/943=286969`M`

_{3}=M/m_{3}=270611767/827=327221**We now calculate the modular multiplicative inverses M**_{1}^{-1}to M_{3}^{-1}

Have a look at the page that explains how to calculate modular multiplicative inverse.

Using, for example, the Extended Euclidean Algorithm, we will find that:

n b q r t1 t2 t3 347 779861 0 347 0 1 0 779861 347 2247 152 1 0 1 347 152 2 43 0 1 -2 152 43 3 23 1 -2 7 43 23 1 20 -2 7 -9 23 20 1 3 7 -9 16 20 3 6 2 -9 16 -105 3 2 1 1 16 -105 121 2 1 2 0 -105 121 -347 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 943 286969 0 943 0 1 0 286969 943 304 297 1 0 1 943 297 3 52 0 1 -3 297 52 5 37 1 -3 16 52 37 1 15 -3 16 -19 37 15 2 7 16 -19 54 15 7 2 1 -19 54 -127 7 1 7 0 54 -127 943 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 827 327221 0 827 0 1 0 327221 827 395 556 1 0 1 827 556 1 271 0 1 -1 556 271 2 14 1 -1 3 271 14 19 5 -1 3 -58 14 5 2 4 3 -58 119 5 4 1 1 -58 119 -177 4 1 4 0 119 -177 827 *Source: ExtendedEuclideanAlgorithm.com*

**Now we can calculate x with the equation we saw earlier**

`x = (a`

_{1}× M_{1}× M_{1}^{-1}+ a_{2}× M_{2}× M_{2}^{-1}+ ... + a_{k}× M_{k}× M_{k}^{-1})**mod M**

`= (86 × 779861 × 121 +`

24 × 286969 × 816 +

454 × 327221 × 650)**mod 270611767**

= 159162393 (mod 270611767)

So our answer is 159162393 (mod 270611767).

Verification

So we found that `x ≡ 159162393`

If this is correct, then the following statements (i.e. the original equations) are true:

215x (mod 347) ≡ 446 (mod 347)

206x (mod 943) ≡ 229 (mod 943)

893x (mod 827) ≡ 192 (mod 827)

Let's see whether that's indeed the case if we use x ≡ 159162393.