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
1736100173010
610173391101
1739118201-1
9182191-12
82991-12-19
91902-19173
So our multiplicative inverse is -19 mod 173 ≡ 154
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
59562059010
56259931101
593112801-1
3128131-12
28391-12-19
31302-1959
So our multiplicative inverse is -19 mod 59 ≡ 40
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7738730773010
8737731100101
77310077301-7
100731271-78
7327219-78-23
2719188-2331
19823-2331-85
832231-85201
3211-85201-286
2120201-286773
So our multiplicative inverse is -286 mod 773 ≡ 487
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 ≡ 418 × 610-1 (mod 173) ≡ 418 × 154 (mod 173) ≡ 16 (mod 173)
x ≡ 340 × 562-1 (mod 59) ≡ 340 × 40 (mod 59) ≡ 30 (mod 59)
x ≡ 396 × 873-1 (mod 773) ≡ 396 × 487 (mod 773) ≡ 375 (mod 773)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 173 × 59 × 773 = 7890011
  2. We calculate the numbers M1 to M3
    M1=M/m1=7890011/173=45607,   M2=M/m2=7890011/59=133729,   M3=M/m3=7890011/773=10207
  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
    173456070173010
    45607173263108101
    17310816501-1
    108651431-12
    6543122-12-3
    43221212-35
    222111-35-8
    2112105-8173
    So our multiplicative inverse is -8 mod 173 ≡ 165
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    59133729059010
    13372959226635101
    593512401-1
    35241111-12
    241122-12-5
    112512-527
    2120-527-59
    So our multiplicative inverse is 27 mod 59 ≡ 27
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    773102070773010
    1020777313158101
    773158414101-4
    1581411171-45
    1411785-45-44
    175325-44137
    5221-44137-318
    2120137-318773
    So our multiplicative inverse is -318 mod 773 ≡ 455
    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
    =  (16 × 45607 × 165 +
       30 × 133729 × 27 +
       375 × 10207 × 455)   mod 7890011
    = 5679606 (mod 7890011)


    So our answer is 5679606 (mod 7890011).


Verification

So we found that x ≡ 5679606
If this is correct, then the following statements (i.e. the original equations) are true:
610x (mod 173) ≡ 418 (mod 173)
562x (mod 59) ≡ 340 (mod 59)
873x (mod 773) ≡ 396 (mod 773)

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