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
6192309101-309
21201-309619
So our multiplicative inverse is -309 mod 619 ≡ 310
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
571144313901-3
144139151-34
1395274-34-111
54114-111115
4140-111115-571
So our multiplicative inverse is 115 mod 571 ≡ 115
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1913352601-5
3326171-56
26735-56-23
75126-2329
5221-2329-81
212029-81191
So our multiplicative inverse is -81 mod 191 ≡ 110
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 ≡ 350 × 2-1 (mod 619) ≡ 350 × 310 (mod 619) ≡ 175 (mod 619)
x ≡ 342 × 144-1 (mod 571) ≡ 342 × 115 (mod 571) ≡ 502 (mod 571)
x ≡ 297 × 33-1 (mod 191) ≡ 297 × 110 (mod 191) ≡ 9 (mod 191)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 619 × 571 × 191 = 67508759
  2. We calculate the numbers M1 to M3
    M1=M/m1=67508759/619=109061,   M2=M/m2=67508759/571=118229,   M3=M/m3=67508759/191=353449
  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
    6191090610619010
    109061619176117101
    61911753401-5
    117343151-516
    341524-516-37
    1543316-37127
    4311-37127-164
    3130127-164619
    So our multiplicative inverse is -164 mod 619 ≡ 455
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5711182290571010
    11822957120732101
    57132172701-17
    3227151-1718
    27552-1718-107
    522118-107232
    2120-107232-571
    So our multiplicative inverse is 232 mod 571 ≡ 232
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1913534490191010
    353449191185099101
    1919919201-1
    9992171-12
    927131-12-27
    71702-27191
    So our multiplicative inverse is -27 mod 191 ≡ 164
    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
    =  (175 × 109061 × 455 +
       502 × 118229 × 232 +
       9 × 353449 × 164)   mod 67508759
    = 22117045 (mod 67508759)


    So our answer is 22117045 (mod 67508759).


Verification

So we found that x ≡ 22117045
If this is correct, then the following statements (i.e. the original equations) are true:
2x (mod 619) ≡ 350 (mod 619)
144x (mod 571) ≡ 342 (mod 571)
33x (mod 191) ≡ 297 (mod 191)

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