Bootstrap
  C.R.T. .com
It doesn't have to be difficult if someone just explains it right.

Welcome to ChineseRemainderTheorem.com!

×

Modal Header

Some text in the Modal Body

Some other text...

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?


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:

nbqr t1t2t3
3598460359010
8463592128101
359128210301-2
1281031251-23
1032543-23-14
253813-14115
3130-14115-359
So our multiplicative inverse is 115 mod 359 ≡ 115
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
961261317801-3
2611781831-34
17883212-34-11
83126114-1170
121111-1170-81
11111070-81961
So our multiplicative inverse is -81 mod 961 ≡ 880
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
985563142201-1
56342211411-12
4221412140-12-5
141140112-57
14011400-57-985
So our multiplicative inverse is 7 mod 985 ≡ 7
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 ≡ 766 × 846-1 (mod 359) ≡ 766 × 115 (mod 359) ≡ 135 (mod 359)
x ≡ 18 × 261-1 (mod 961) ≡ 18 × 880 (mod 961) ≡ 464 (mod 961)
x ≡ 237 × 563-1 (mod 985) ≡ 237 × 7 (mod 985) ≡ 674 (mod 985)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 359 × 961 × 985 = 339824015
  2. We calculate the numbers M1 to M3
    M1=M/m1=339824015/359=946585,   M2=M/m2=339824015/961=353615,   M3=M/m3=339824015/985=344999
  3. We now calculate the modular multiplicative inverses M1-1 to M3-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:

    nbqr t1t2t3
    3599465850359010
    9465853592636261101
    35926119801-1
    261982651-13
    9865133-13-4
    65331323-47
    333211-47-11
    3213207-11359
    So our multiplicative inverse is -11 mod 359 ≡ 348
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9613536150961010
    353615961367928101
    96192813301-1
    928332841-129
    33481-129-233
    414029-233961
    So our multiplicative inverse is -233 mod 961 ≡ 728
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9853449990985010
    344999985350249101
    985249323801-3
    2492381111-34
    23811217-34-87
    117144-8791
    7413-8791-178
    431191-178269
    3130-178269-985
    So our multiplicative inverse is 269 mod 985 ≡ 269
    Source: ExtendedEuclideanAlgorithm.com
  4. Now we can calculate x with the equation we saw earlier
    x = (a1 × M1 × M1-1   +   a2 × M2 × M2-1   + ... +   ak × Mk × Mk-1)   mod M
    =  (135 × 946585 × 348 +
       464 × 353615 × 728 +
       674 × 344999 × 269)   mod 339824015
    = 146476084 (mod 339824015)


    So our answer is 146476084 (mod 339824015).


Verification

So we found that x ≡ 146476084
If this is correct, then the following statements (i.e. the original equations) are true:
846x (mod 359) ≡ 766 (mod 359)
261x (mod 961) ≡ 18 (mod 961)
563x (mod 985) ≡ 237 (mod 985)

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