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

757 | 271 | 2 | 215 | 0 | 1 | -2 |

271 | 215 | 1 | 56 | 1 | -2 | 3 |

215 | 56 | 3 | 47 | -2 | 3 | -11 |

56 | 47 | 1 | 9 | 3 | -11 | 14 |

47 | 9 | 5 | 2 | -11 | 14 | -81 |

9 | 2 | 4 | 1 | 14 | -81 | 338 |

2 | 1 | 2 | 0 | -81 | 338 | -757 |

*Source: ExtendedEuclideanAlgorithm.com*

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

283 | 796 | 0 | 283 | 0 | 1 | 0 |

796 | 283 | 2 | 230 | 1 | 0 | 1 |

283 | 230 | 1 | 53 | 0 | 1 | -1 |

230 | 53 | 4 | 18 | 1 | -1 | 5 |

53 | 18 | 2 | 17 | -1 | 5 | -11 |

18 | 17 | 1 | 1 | 5 | -11 | 16 |

17 | 1 | 17 | 0 | -11 | 16 | -283 |

*Source: ExtendedEuclideanAlgorithm.com*

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

537 | 197 | 2 | 143 | 0 | 1 | -2 |

197 | 143 | 1 | 54 | 1 | -2 | 3 |

143 | 54 | 2 | 35 | -2 | 3 | -8 |

54 | 35 | 1 | 19 | 3 | -8 | 11 |

35 | 19 | 1 | 16 | -8 | 11 | -19 |

19 | 16 | 1 | 3 | 11 | -19 | 30 |

16 | 3 | 5 | 1 | -19 | 30 | -169 |

3 | 1 | 3 | 0 | 30 | -169 | 537 |

*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 ≡ 922 × 271`

^{-1} (mod 757) ≡ 922 × 338 (mod 757) ≡ 509 (mod 757)`x ≡ 813 × 796`

^{-1} (mod 283) ≡ 813 × 16 (mod 283) ≡ 273 (mod 283)`x ≡ 615 × 197`

^{-1} (mod 537) ≡ 615 × 368 (mod 537) ≡ 243 (mod 537)

**New equations**

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

x ≡ 509 (mod 757)

x ≡ 273 (mod 283)

x ≡ 243 (mod 537)

Now the actual calculation

**Find the common modulus M**

`M = m`

_{1}× m_{2}× ... × m_{k}= 757 × 283 × 537 = 115042047**We calculate the numbers M**_{1}to M_{3}

`M`

,_{1}=M/m_{1}=115042047/757=151971`M`

,_{2}=M/m_{2}=115042047/283=406509`M`

_{3}=M/m_{3}=115042047/537=214231**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 757 151971 0 757 0 1 0 151971 757 200 571 1 0 1 757 571 1 186 0 1 -1 571 186 3 13 1 -1 4 186 13 14 4 -1 4 -57 13 4 3 1 4 -57 175 4 1 4 0 -57 175 -757 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 283 406509 0 283 0 1 0 406509 283 1436 121 1 0 1 283 121 2 41 0 1 -2 121 41 2 39 1 -2 5 41 39 1 2 -2 5 -7 39 2 19 1 5 -7 138 2 1 2 0 -7 138 -283 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 537 214231 0 537 0 1 0 214231 537 398 505 1 0 1 537 505 1 32 0 1 -1 505 32 15 25 1 -1 16 32 25 1 7 -1 16 -17 25 7 3 4 16 -17 67 7 4 1 3 -17 67 -84 4 3 1 1 67 -84 151 3 1 3 0 -84 151 -537 *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**

`= (509 × 151971 × 175 +`

273 × 406509 × 138 +

243 × 214231 × 151)**mod 115042047**

= 14001981 (mod 115042047)

So our answer is 14001981 (mod 115042047).

Verification

So we found that `x ≡ 14001981`

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

271x (mod 757) ≡ 922 (mod 757)

796x (mod 283) ≡ 813 (mod 283)

197x (mod 537) ≡ 615 (mod 537)

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