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
87784613101-1
846312791-128
31934-128-85
942128-85198
4140-85198-877
So our multiplicative inverse is 198 mod 877 ≡ 198
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
669386128301-1
38628311031-12
283103277-12-5
103771262-57
7726225-57-19
2625117-1926
251250-1926-669
So our multiplicative inverse is 26 mod 669 ≡ 26
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
75169715401-1
6975412491-113
544915-113-14
4959413-14139
5411-14139-153
4140139-153751
So our multiplicative inverse is -153 mod 751 ≡ 598
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 ≡ 297 × 846-1 (mod 877) ≡ 297 × 198 (mod 877) ≡ 47 (mod 877)
x ≡ 828 × 386-1 (mod 669) ≡ 828 × 26 (mod 669) ≡ 120 (mod 669)
x ≡ 266 × 697-1 (mod 751) ≡ 266 × 598 (mod 751) ≡ 607 (mod 751)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 877 × 669 × 751 = 440621463
  2. We calculate the numbers M1 to M3
    M1=M/m1=440621463/877=502419,   M2=M/m2=440621463/669=658627,   M3=M/m3=440621463/751=586713
  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
    8775024190877010
    502419877572775101
    877775110201-1
    7751027611-18
    10261141-18-9
    61411208-917
    412021-917-43
    20120017-43877
    So our multiplicative inverse is -43 mod 877 ≡ 834
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6696586270669010
    658627669984331101
    6693312701-2
    33174721-295
    7231-295-287
    212095-287669
    So our multiplicative inverse is -287 mod 669 ≡ 382
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7515867130751010
    586713751781182101
    75118242301-4
    182237211-429
    232112-429-33
    21210129-33359
    2120-33359-751
    So our multiplicative inverse is 359 mod 751 ≡ 359
    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
    =  (47 × 502419 × 834 +
       120 × 658627 × 382 +
       607 × 586713 × 359)   mod 440621463
    = 167222022 (mod 440621463)


    So our answer is 167222022 (mod 440621463).


Verification

So we found that x ≡ 167222022
If this is correct, then the following statements (i.e. the original equations) are true:
846x (mod 877) ≡ 297 (mod 877)
386x (mod 669) ≡ 828 (mod 669)
697x (mod 751) ≡ 266 (mod 751)

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