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
3113780311010
378311167101
3116744301-4
67431241-45
4324119-45-9
2419155-914
19534-914-51
541114-5165
4140-5165-311
So our multiplicative inverse is 65 mod 311 ≡ 65
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1693890169010
389169251101
1695131601-3
5116331-310
16351-310-53
313010-53169
So our multiplicative inverse is -53 mod 169 ≡ 116
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4989470498010
9474981449101
49844914901-1
44949981-110
49861-110-61
818010-61498
So our multiplicative inverse is -61 mod 498 ≡ 437
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 ≡ 188 × 378-1 (mod 311) ≡ 188 × 65 (mod 311) ≡ 91 (mod 311)
x ≡ 593 × 389-1 (mod 169) ≡ 593 × 116 (mod 169) ≡ 5 (mod 169)
x ≡ 328 × 947-1 (mod 498) ≡ 328 × 437 (mod 498) ≡ 410 (mod 498)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 311 × 169 × 498 = 26174382
  2. We calculate the numbers M1 to M3
    M1=M/m1=26174382/311=84162,   M2=M/m2=26174382/169=154878,   M3=M/m3=26174382/498=52559
  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
    311841620311010
    84162311270192101
    311192111901-1
    1921191731-12
    11973146-12-3
    73461272-35
    4627119-35-8
    2719185-813
    19823-813-34
    832213-3481
    3211-3481-115
    212081-115311
    So our multiplicative inverse is -115 mod 311 ≡ 196
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1691548780169010
    15487816991674101
    1697422101-2
    74213111-27
    2111110-27-9
    1110117-916
    101100-916-169
    So our multiplicative inverse is 16 mod 169 ≡ 16
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    498525590498010
    52559498105269101
    498269122901-1
    2692291401-12
    22940529-12-11
    40291112-1113
    291127-1113-37
    1171413-3750
    7413-3750-87
    431150-87137
    3130-87137-498
    So our multiplicative inverse is 137 mod 498 ≡ 137
    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
    =  (91 × 84162 × 196 +
       5 × 154878 × 16 +
       410 × 52559 × 137)   mod 26174382
    = 16097762 (mod 26174382)


    So our answer is 16097762 (mod 26174382).


Verification

So we found that x ≡ 16097762
If this is correct, then the following statements (i.e. the original equations) are true:
378x (mod 311) ≡ 188 (mod 311)
389x (mod 169) ≡ 593 (mod 169)
947x (mod 498) ≡ 328 (mod 498)

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