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
1018620101010
862101854101
1015414701-1
5447171-12
47765-12-13
75122-1315
5221-1315-43
212015-43101
So our multiplicative inverse is -43 mod 101 ≡ 58
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7877970787010
797787110101
7871078701-78
107131-7879
7321-7879-236
313079-236787
So our multiplicative inverse is -236 mod 787 ≡ 551
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
94429934701-3
299476171-319
4717213-319-41
17131419-4160
13431-4160-221
414060-221944
So our multiplicative inverse is -221 mod 944 ≡ 723
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 ≡ 649 × 862-1 (mod 101) ≡ 649 × 58 (mod 101) ≡ 70 (mod 101)
x ≡ 597 × 797-1 (mod 787) ≡ 597 × 551 (mod 787) ≡ 768 (mod 787)
x ≡ 127 × 299-1 (mod 944) ≡ 127 × 723 (mod 944) ≡ 253 (mod 944)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 101 × 787 × 944 = 75035728
  2. We calculate the numbers M1 to M3
    M1=M/m1=75035728/101=742928,   M2=M/m2=75035728/787=95344,   M3=M/m3=75035728/944=79487
  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
    1017429280101010
    742928101735573101
    1017312801-1
    73282171-13
    2817111-13-4
    1711163-47
    11615-47-11
    65117-1118
    5150-1118-101
    So our multiplicative inverse is 18 mod 101 ≡ 18
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    787953440787010
    95344787121117101
    78711768501-6
    117851321-67
    8532221-67-20
    32211117-2027
    2111110-2027-47
    11101127-4774
    101100-4774-787
    So our multiplicative inverse is 74 mod 787 ≡ 74
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    944794870944010
    7948794484191101
    944191418001-4
    1911801111-45
    18011164-45-84
    114235-84173
    4311-84173-257
    3130173-257944
    So our multiplicative inverse is -257 mod 944 ≡ 687
    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
    =  (70 × 742928 × 18 +
       768 × 95344 × 74 +
       253 × 79487 × 687)   mod 75035728
    = 60819341 (mod 75035728)


    So our answer is 60819341 (mod 75035728).


Verification

So we found that x ≡ 60819341
If this is correct, then the following statements (i.e. the original equations) are true:
862x (mod 101) ≡ 649 (mod 101)
797x (mod 787) ≡ 597 (mod 787)
299x (mod 944) ≡ 127 (mod 944)

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