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
4277300427010
7304271303101
427303112401-1
3031242551-13
12455214-13-7
55143133-724
141311-724-31
13113024-31427
So our multiplicative inverse is -31 mod 427 ≡ 396
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
804517128701-1
51728712301-12
287230157-12-3
23057422-314
572281-314-395
212014-395804
So our multiplicative inverse is -395 mod 804 ≡ 409
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1937670193010
7671933188101
1931881501-1
18853731-138
5312-138-39
321138-3977
2120-3977-193
So our multiplicative inverse is 77 mod 193 ≡ 77
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 ≡ 859 × 730-1 (mod 427) ≡ 859 × 396 (mod 427) ≡ 272 (mod 427)
x ≡ 234 × 517-1 (mod 804) ≡ 234 × 409 (mod 804) ≡ 30 (mod 804)
x ≡ 158 × 767-1 (mod 193) ≡ 158 × 77 (mod 193) ≡ 7 (mod 193)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 427 × 804 × 193 = 66258444
  2. We calculate the numbers M1 to M3
    M1=M/m1=66258444/427=155172,   M2=M/m2=66258444/804=82411,   M3=M/m3=66258444/193=343308
  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
    4271551720427010
    155172427363171101
    42717128501-2
    17185211-25
    851850-25-427
    So our multiplicative inverse is 5 mod 427 ≡ 5
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    804824110804010
    82411804102403101
    804403140101-1
    403401121-12
    40122001-12-401
    21202-401804
    So our multiplicative inverse is -401 mod 804 ≡ 403
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1933433080193010
    3433081931778154101
    19315413901-1
    154393371-14
    393712-14-5
    3721814-594
    2120-594-193
    So our multiplicative inverse is 94 mod 193 ≡ 94
    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
    =  (272 × 155172 × 5 +
       30 × 82411 × 403 +
       7 × 343308 × 94)   mod 66258444
    = 41852250 (mod 66258444)


    So our answer is 41852250 (mod 66258444).


Verification

So we found that x ≡ 41852250
If this is correct, then the following statements (i.e. the original equations) are true:
730x (mod 427) ≡ 859 (mod 427)
517x (mod 804) ≡ 234 (mod 804)
767x (mod 193) ≡ 158 (mod 193)

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