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
943478146501-1
4784651131-12
465133510-12-71
1310132-7173
10331-7173-290
313073-290943
So our multiplicative inverse is -290 mod 943 ≡ 653
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
977829114801-1
8291485891-16
14889159-16-7
89591306-713
5930129-713-20
30291113-2033
291290-2033-977
So our multiplicative inverse is 33 mod 977 ≡ 33
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
64758216501-1
582658621-19
656213-19-10
6232029-10209
3211-10209-219
2120209-219647
So our multiplicative inverse is -219 mod 647 ≡ 428
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 ≡ 327 × 478-1 (mod 943) ≡ 327 × 653 (mod 943) ≡ 413 (mod 943)
x ≡ 656 × 829-1 (mod 977) ≡ 656 × 33 (mod 977) ≡ 154 (mod 977)
x ≡ 718 × 582-1 (mod 647) ≡ 718 × 428 (mod 647) ≡ 626 (mod 647)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 943 × 977 × 647 = 596088217
  2. We calculate the numbers M1 to M3
    M1=M/m1=596088217/943=632119,   M2=M/m2=596088217/977=610121,   M3=M/m3=596088217/647=921311
  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
    9436321190943010
    632119943670309101
    94330931601-3
    309161951-358
    16531-358-177
    515058-177943
    So our multiplicative inverse is -177 mod 943 ≡ 766
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9776101210977010
    610121977624473101
    97747323101-2
    473311581-231
    31837-231-95
    871131-95126
    7170-95126-977
    So our multiplicative inverse is 126 mod 977 ≡ 126
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6479213110647010
    9213116471423630101
    64763011701-1
    630173711-138
    171170-138-647
    So our multiplicative inverse is 38 mod 647 ≡ 38
    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
    =  (413 × 632119 × 766 +
       154 × 610121 × 126 +
       626 × 921311 × 38)   mod 596088217
    = 64255490 (mod 596088217)


    So our answer is 64255490 (mod 596088217).


Verification

So we found that x ≡ 64255490
If this is correct, then the following statements (i.e. the original equations) are true:
478x (mod 943) ≡ 327 (mod 943)
829x (mod 977) ≡ 656 (mod 977)
582x (mod 647) ≡ 718 (mod 647)

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