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
3599370359010
9373592219101
359219114001-1
2191401791-12
14079161-12-3
79611182-35
611837-35-18
187245-1841
7413-1841-59
431141-59100
3130-59100-359
So our multiplicative inverse is 100 mod 359 ≡ 100
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7814119201-19
4122011-19381
2120-19381-781
So our multiplicative inverse is 381 mod 781 ≡ 381
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
97713771801-7
137187111-750
181117-750-57
1171450-57107
7413-57107-164
4311107-164271
3130-164271-977
So our multiplicative inverse is 271 mod 977 ≡ 271
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 ≡ 360 × 937-1 (mod 359) ≡ 360 × 100 (mod 359) ≡ 100 (mod 359)
x ≡ 293 × 41-1 (mod 781) ≡ 293 × 381 (mod 781) ≡ 731 (mod 781)
x ≡ 409 × 137-1 (mod 977) ≡ 409 × 271 (mod 977) ≡ 438 (mod 977)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 359 × 781 × 977 = 273930283
  2. We calculate the numbers M1 to M3
    M1=M/m1=273930283/359=763037,   M2=M/m2=273930283/781=350743,   M3=M/m3=273930283/977=280379
  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
    3597630370359010
    7630373592125162101
    35916223501-2
    162354221-29
    3522113-29-11
    2213199-1120
    13914-1120-31
    942120-3182
    4140-3182-359
    So our multiplicative inverse is 82 mod 359 ≡ 82
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7813507430781010
    35074378144974101
    78174104101-10
    74411331-1011
    413318-1011-21
    3384111-2195
    8180-2195-781
    So our multiplicative inverse is 95 mod 781 ≡ 95
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9772803790977010
    280379977286957101
    97795712001-1
    9572047171-148
    201713-148-49
    1735248-49293
    3211-49293-342
    2120293-342977
    So our multiplicative inverse is -342 mod 977 ≡ 635
    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
    =  (100 × 763037 × 82 +
       731 × 350743 × 95 +
       438 × 280379 × 635)   mod 273930283
    = 119670237 (mod 273930283)


    So our answer is 119670237 (mod 273930283).


Verification

So we found that x ≡ 119670237
If this is correct, then the following statements (i.e. the original equations) are true:
937x (mod 359) ≡ 360 (mod 359)
41x (mod 781) ≡ 293 (mod 781)
137x (mod 977) ≡ 409 (mod 977)

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