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

739 | 671 | 1 | 68 | 0 | 1 | -1 |

671 | 68 | 9 | 59 | 1 | -1 | 10 |

68 | 59 | 1 | 9 | -1 | 10 | -11 |

59 | 9 | 6 | 5 | 10 | -11 | 76 |

9 | 5 | 1 | 4 | -11 | 76 | -87 |

5 | 4 | 1 | 1 | 76 | -87 | 163 |

4 | 1 | 4 | 0 | -87 | 163 | -739 |

*Source: ExtendedEuclideanAlgorithm.com*

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

269 | 922 | 0 | 269 | 0 | 1 | 0 |

922 | 269 | 3 | 115 | 1 | 0 | 1 |

269 | 115 | 2 | 39 | 0 | 1 | -2 |

115 | 39 | 2 | 37 | 1 | -2 | 5 |

39 | 37 | 1 | 2 | -2 | 5 | -7 |

37 | 2 | 18 | 1 | 5 | -7 | 131 |

2 | 1 | 2 | 0 | -7 | 131 | -269 |

*Source: ExtendedEuclideanAlgorithm.com*

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

683 | 234 | 2 | 215 | 0 | 1 | -2 |

234 | 215 | 1 | 19 | 1 | -2 | 3 |

215 | 19 | 11 | 6 | -2 | 3 | -35 |

19 | 6 | 3 | 1 | 3 | -35 | 108 |

6 | 1 | 6 | 0 | -35 | 108 | -683 |

*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 ≡ 637 × 671`

^{-1} (mod 739) ≡ 637 × 163 (mod 739) ≡ 371 (mod 739)`x ≡ 638 × 922`

^{-1} (mod 269) ≡ 638 × 131 (mod 269) ≡ 188 (mod 269)`x ≡ 405 × 234`

^{-1} (mod 683) ≡ 405 × 108 (mod 683) ≡ 28 (mod 683)

**New equations**

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

x ≡ 371 (mod 739)

x ≡ 188 (mod 269)

x ≡ 28 (mod 683)

Now the actual calculation

**Find the common modulus M**

`M = m`

_{1}× m_{2}× ... × m_{k}= 739 × 269 × 683 = 135774253**We calculate the numbers M**_{1}to M_{3}

`M`

,_{1}=M/m_{1}=135774253/739=183727`M`

,_{2}=M/m_{2}=135774253/269=504737`M`

_{3}=M/m_{3}=135774253/683=198791**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 739 183727 0 739 0 1 0 183727 739 248 455 1 0 1 739 455 1 284 0 1 -1 455 284 1 171 1 -1 2 284 171 1 113 -1 2 -3 171 113 1 58 2 -3 5 113 58 1 55 -3 5 -8 58 55 1 3 5 -8 13 55 3 18 1 -8 13 -242 3 1 3 0 13 -242 739 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 269 504737 0 269 0 1 0 504737 269 1876 93 1 0 1 269 93 2 83 0 1 -2 93 83 1 10 1 -2 3 83 10 8 3 -2 3 -26 10 3 3 1 3 -26 81 3 1 3 0 -26 81 -269 *Source: ExtendedEuclideanAlgorithm.com*

n b q r t1 t2 t3 683 198791 0 683 0 1 0 198791 683 291 38 1 0 1 683 38 17 37 0 1 -17 38 37 1 1 1 -17 18 37 1 37 0 -17 18 -683 *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**

`= (371 × 183727 × 497 +`

188 × 504737 × 81 +

28 × 198791 × 18)**mod 135774253**

= 116274631 (mod 135774253)

So our answer is 116274631 (mod 135774253).

Verification

So we found that `x ≡ 116274631`

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

671x (mod 739) ≡ 637 (mod 739)

922x (mod 269) ≡ 638 (mod 269)

234x (mod 683) ≡ 405 (mod 683)

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