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
97487519901-1
875998831-19
9983116-19-10
8316539-1059
16351-1059-305
313059-305974
So our multiplicative inverse is -305 mod 974 ≡ 669
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3133682501-8
36251111-89
251123-89-26
113329-2687
3211-2687-113
212087-113313
So our multiplicative inverse is -113 mod 313 ≡ 200
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3491131801-31
118131-3132
8322-3132-95
321132-95127
2120-95127-349
So our multiplicative inverse is 127 mod 349 ≡ 127
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 ≡ 301 × 875-1 (mod 974) ≡ 301 × 669 (mod 974) ≡ 725 (mod 974)
x ≡ 22 × 36-1 (mod 313) ≡ 22 × 200 (mod 313) ≡ 18 (mod 313)
x ≡ 144 × 11-1 (mod 349) ≡ 144 × 127 (mod 349) ≡ 140 (mod 349)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 974 × 313 × 349 = 106396838
  2. We calculate the numbers M1 to M3
    M1=M/m1=106396838/974=109237,   M2=M/m2=106396838/313=339926,   M3=M/m3=106396838/349=304862
  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
    9741092370974010
    109237974112149101
    97414968001-6
    149801691-67
    8069111-67-13
    6911637-1385
    11332-1385-268
    321185-268353
    2120-268353-974
    So our multiplicative inverse is 353 mod 974 ≡ 353
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3133399260313010
    33992631310868101
    313839101-39
    81801-39313
    So our multiplicative inverse is -39 mod 313 ≡ 274
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3493048620349010
    304862349873185101
    349185116401-1
    1851641211-12
    16421717-12-15
    2117142-1517
    17441-1517-83
    414017-83349
    So our multiplicative inverse is -83 mod 349 ≡ 266
    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
    =  (725 × 109237 × 353 +
       18 × 339926 × 274 +
       140 × 304862 × 266)   mod 106396838
    = 23272507 (mod 106396838)


    So our answer is 23272507 (mod 106396838).


Verification

So we found that x ≡ 23272507
If this is correct, then the following statements (i.e. the original equations) are true:
875x (mod 974) ≡ 301 (mod 974)
36x (mod 313) ≡ 22 (mod 313)
11x (mod 349) ≡ 144 (mod 349)

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