# 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 |
---|---|---|---|---|---|---|

377 | 63 | 5 | 62 | 0 | 1 | -5 |

63 | 62 | 1 | 1 | 1 | -5 | 6 |

62 | 1 | 62 | 0 | -5 | 6 | -377 |

*Source: ExtendedEuclideanAlgorithm.com*

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

626 | 205 | 3 | 11 | 0 | 1 | -3 |

205 | 11 | 18 | 7 | 1 | -3 | 55 |

11 | 7 | 1 | 4 | -3 | 55 | -58 |

7 | 4 | 1 | 3 | 55 | -58 | 113 |

4 | 3 | 1 | 1 | -58 | 113 | -171 |

3 | 1 | 3 | 0 | 113 | -171 | 626 |

*Source: ExtendedEuclideanAlgorithm.com*

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

889 | 244 | 3 | 157 | 0 | 1 | -3 |

244 | 157 | 1 | 87 | 1 | -3 | 4 |

157 | 87 | 1 | 70 | -3 | 4 | -7 |

87 | 70 | 1 | 17 | 4 | -7 | 11 |

70 | 17 | 4 | 2 | -7 | 11 | -51 |

17 | 2 | 8 | 1 | 11 | -51 | 419 |

2 | 1 | 2 | 0 | -51 | 419 | -889 |

*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 ≡ 127 × 63`

^{-1} (mod 377) ≡ 127 × 6 (mod 377) ≡ 8 (mod 377)`x ≡ 94 × 205`

^{-1} (mod 626) ≡ 94 × 455 (mod 626) ≡ 202 (mod 626)`x ≡ 298 × 244`

^{-1} (mod 889) ≡ 298 × 419 (mod 889) ≡ 402 (mod 889)

**New equations**

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

x ≡ 8 (mod 377)

x ≡ 202 (mod 626)

x ≡ 402 (mod 889)

Now the actual calculation

**Find the common modulus M**

`M = m`

_{1}× m_{2}× ... × m_{k}= 377 × 626 × 889 = 209805778**We calculate the numbers M**_{1}to M_{3}

`M`

,_{1}=M/m_{1}=209805778/377=556514`M`

,_{2}=M/m_{2}=209805778/626=335153`M`

_{3}=M/m_{3}=209805778/889=236002**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 377 556514 0 377 0 1 0 556514 377 1476 62 1 0 1 377 62 6 5 0 1 -6 62 5 12 2 1 -6 73 5 2 2 1 -6 73 -152 2 1 2 0 73 -152 377 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 626 335153 0 626 0 1 0 335153 626 535 243 1 0 1 626 243 2 140 0 1 -2 243 140 1 103 1 -2 3 140 103 1 37 -2 3 -5 103 37 2 29 3 -5 13 37 29 1 8 -5 13 -18 29 8 3 5 13 -18 67 8 5 1 3 -18 67 -85 5 3 1 2 67 -85 152 3 2 1 1 -85 152 -237 2 1 2 0 152 -237 626 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 889 236002 0 889 0 1 0 236002 889 265 417 1 0 1 889 417 2 55 0 1 -2 417 55 7 32 1 -2 15 55 32 1 23 -2 15 -17 32 23 1 9 15 -17 32 23 9 2 5 -17 32 -81 9 5 1 4 32 -81 113 5 4 1 1 -81 113 -194 4 1 4 0 113 -194 889 *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**

`= (8 × 556514 × 225 +`

202 × 335153 × 389 +

402 × 236002 × 695)**mod 209805778**

= 120210982 (mod 209805778)

So our answer is 120210982 (mod 209805778).

Verification

So we found that `x ≡ 120210982`

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

63x (mod 377) ≡ 127 (mod 377)

205x (mod 626) ≡ 94 (mod 626)

244x (mod 889) ≡ 298 (mod 889)

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