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
3735120373010
5123731139101
37313929501-2
139951441-23
954427-23-8
447623-851
7231-851-161
212051-161373
So our multiplicative inverse is -161 mod 373 ≡ 212
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
40138411701-1
3841722101-123
171017-123-24
1071323-2447
7321-2447-118
313047-118401
So our multiplicative inverse is -118 mod 401 ≡ 283
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3554770355010
4773551122101
355122211101-2
1221111111-23
11111101-23-32
1111103-32355
So our multiplicative inverse is -32 mod 355 ≡ 323
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 ≡ 609 × 512-1 (mod 373) ≡ 609 × 212 (mod 373) ≡ 50 (mod 373)
x ≡ 128 × 384-1 (mod 401) ≡ 128 × 283 (mod 401) ≡ 134 (mod 401)
x ≡ 313 × 477-1 (mod 355) ≡ 313 × 323 (mod 355) ≡ 279 (mod 355)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 373 × 401 × 355 = 53098415
  2. We calculate the numbers M1 to M3
    M1=M/m1=53098415/373=142355,   M2=M/m2=53098415/401=132415,   M3=M/m3=53098415/355=149573
  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
    3731423550373010
    142355373381242101
    373242113101-1
    24213111111-12
    131111120-12-3
    111205112-317
    201119-317-20
    1191217-2037
    9241-2037-168
    212037-168373
    So our multiplicative inverse is -168 mod 373 ≡ 205
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4011324150401010
    13241540133085101
    4018546101-4
    85611241-45
    6124213-45-14
    24131115-1419
    131112-1419-33
    1125119-33184
    2120-33184-401
    So our multiplicative inverse is 184 mod 401 ≡ 184
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3551495730355010
    149573355421118101
    3551183101-3
    118111801-3355
    So our multiplicative inverse is -3 mod 355 ≡ 352
    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
    =  (50 × 142355 × 205 +
       134 × 132415 × 184 +
       279 × 149573 × 352)   mod 53098415
    = 32306699 (mod 53098415)


    So our answer is 32306699 (mod 53098415).


Verification

So we found that x ≡ 32306699
If this is correct, then the following statements (i.e. the original equations) are true:
512x (mod 373) ≡ 609 (mod 373)
384x (mod 401) ≡ 128 (mod 401)
477x (mod 355) ≡ 313 (mod 355)

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