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
991342230701-2
3423071351-23
30735827-23-26
3527183-2629
27833-2629-113
832229-113255
3211-113255-368
2120255-368991
So our multiplicative inverse is -368 mod 991 ≡ 623
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
949106810101-8
106101151-89
1015201-89-188
51509-188949
So our multiplicative inverse is -188 mod 949 ≡ 761
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
877153511201-5
1531121411-56
11241230-56-17
41301116-1723
301128-1723-63
1181323-6386
8322-6386-235
321186-235321
2120-235321-877
So our multiplicative inverse is 321 mod 877 ≡ 321
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 ≡ 506 × 342-1 (mod 991) ≡ 506 × 623 (mod 991) ≡ 100 (mod 991)
x ≡ 207 × 106-1 (mod 949) ≡ 207 × 761 (mod 949) ≡ 942 (mod 949)
x ≡ 906 × 153-1 (mod 877) ≡ 906 × 321 (mod 877) ≡ 539 (mod 877)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 991 × 949 × 877 = 824782543
  2. We calculate the numbers M1 to M3
    M1=M/m1=824782543/991=832273,   M2=M/m2=824782543/949=869107,   M3=M/m3=824782543/877=940459
  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
    9918322730991010
    832273991839824101
    991824116701-1
    82416741561-15
    167156111-15-6
    156111425-689
    11251-689-451
    212089-451991
    So our multiplicative inverse is -451 mod 991 ≡ 540
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9498691070949010
    869107949915772101
    949772117701-1
    7721774641-15
    17764249-15-11
    64491155-1116
    491534-1116-59
    1543316-59193
    4311-59193-252
    3130193-252949
    So our multiplicative inverse is -252 mod 949 ≡ 697
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8779404590877010
    9404598771072315101
    877315224701-2
    3152471681-23
    24768343-23-11
    68431253-1114
    4325118-1114-25
    25181714-2539
    18724-2539-103
    741339-103142
    4311-103142-245
    3130142-245877
    So our multiplicative inverse is -245 mod 877 ≡ 632
    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
    =  (100 × 832273 × 540 +
       942 × 869107 × 697 +
       539 × 940459 × 632)   mod 824782543
    = 637875088 (mod 824782543)


    So our answer is 637875088 (mod 824782543).


Verification

So we found that x ≡ 637875088
If this is correct, then the following statements (i.e. the original equations) are true:
342x (mod 991) ≡ 506 (mod 991)
106x (mod 949) ≡ 207 (mod 949)
153x (mod 877) ≡ 906 (mod 877)

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