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
3834480383010
448383165101
3836555801-5
6558171-56
58782-56-53
72316-53165
2120-53165-383
So our multiplicative inverse is 165 mod 383 ≡ 165
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
563309125401-1
3092541551-12
25455434-12-9
55341212-911
3421113-911-20
21131811-2031
13815-2031-51
851331-5182
5312-5182-133
321182-133215
2120-133215-563
So our multiplicative inverse is 215 mod 563 ≡ 215
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4079450407010
9454072131101
40713131401-3
13114951-328
14524-328-59
541128-5987
4140-5987-407
So our multiplicative inverse is 87 mod 407 ≡ 87
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 ≡ 941 × 448-1 (mod 383) ≡ 941 × 165 (mod 383) ≡ 150 (mod 383)
x ≡ 822 × 309-1 (mod 563) ≡ 822 × 215 (mod 563) ≡ 511 (mod 563)
x ≡ 953 × 945-1 (mod 407) ≡ 953 × 87 (mod 407) ≡ 290 (mod 407)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 383 × 563 × 407 = 87761003
  2. We calculate the numbers M1 to M3
    M1=M/m1=87761003/383=229141,   M2=M/m2=87761003/563=155881,   M3=M/m3=87761003/407=215629
  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
    3832291410383010
    229141383598107101
    38310736201-3
    107621451-34
    6245117-34-7
    45172114-718
    171116-718-25
    1161518-2543
    6511-2543-68
    515043-68383
    So our multiplicative inverse is -68 mod 383 ≡ 315
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5631558810563010
    155881563276493101
    56349317001-1
    49370731-18
    703231-18-185
    31308-185563
    So our multiplicative inverse is -185 mod 563 ≡ 378
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4072156290407010
    215629407529326101
    40732618101-1
    32681421-15
    812401-15-201
    21205-201407
    So our multiplicative inverse is -201 mod 407 ≡ 206
    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
    =  (150 × 229141 × 315 +
       511 × 155881 × 378 +
       290 × 215629 × 206)   mod 87761003
    = 20756069 (mod 87761003)


    So our answer is 20756069 (mod 87761003).


Verification

So we found that x ≡ 20756069
If this is correct, then the following statements (i.e. the original equations) are true:
448x (mod 383) ≡ 941 (mod 383)
309x (mod 563) ≡ 822 (mod 563)
945x (mod 407) ≡ 953 (mod 407)

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