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
38317024301-2
170433411-27
434112-27-9
4122017-9187
2120-9187-383
So our multiplicative inverse is 187 mod 383 ≡ 187
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1396490139010
649139493101
1399314601-1
9346211-13
461460-13-139
So our multiplicative inverse is 3 mod 139 ≡ 3
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1165350116010
535116471101
1167114501-1
71451261-12
4526119-12-3
2619172-35
19725-35-13
75125-1318
5221-1318-49
212018-49116
So our multiplicative inverse is -49 mod 116 ≡ 67
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 ≡ 458 × 170-1 (mod 383) ≡ 458 × 187 (mod 383) ≡ 237 (mod 383)
x ≡ 266 × 649-1 (mod 139) ≡ 266 × 3 (mod 139) ≡ 103 (mod 139)
x ≡ 859 × 535-1 (mod 116) ≡ 859 × 67 (mod 116) ≡ 17 (mod 116)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 383 × 139 × 116 = 6175492
  2. We calculate the numbers M1 to M3
    M1=M/m1=6175492/383=16124,   M2=M/m2=6175492/139=44428,   M3=M/m3=6175492/116=53237
  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
    383161240383010
    161243834238101
    3833810301-10
    3831221-10121
    3211-10121-131
    2120121-131383
    So our multiplicative inverse is -131 mod 383 ≡ 252
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    139444280139010
    4442813931987101
    1398715201-1
    87521351-12
    5235117-12-3
    3517212-38
    171170-38-139
    So our multiplicative inverse is 8 mod 139 ≡ 8
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    116532370116010
    53237116458109101
    1161091701-1
    10971541-116
    7413-116-17
    431116-1733
    3130-1733-116
    So our multiplicative inverse is 33 mod 116 ≡ 33
    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
    =  (237 × 16124 × 252 +
       103 × 44428 × 8 +
       17 × 53237 × 33)   mod 6175492
    = 4332733 (mod 6175492)


    So our answer is 4332733 (mod 6175492).


Verification

So we found that x ≡ 4332733
If this is correct, then the following statements (i.e. the original equations) are true:
170x (mod 383) ≡ 458 (mod 383)
649x (mod 139) ≡ 266 (mod 139)
535x (mod 116) ≡ 859 (mod 116)

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