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
523394112901-1
394129371-14
1297183-14-73
73214-73150
3130-73150-523
So our multiplicative inverse is 150 mod 523 ≡ 150
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4977200497010
7204971223101
49722325101-2
223514191-29
5119213-29-20
1913169-2029
13621-2029-78
616029-78497
So our multiplicative inverse is -78 mod 497 ≡ 419
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1092760109010
276109258101
1095815101-1
5851171-12
51772-12-15
72312-1547
2120-1547-109
So our multiplicative inverse is 47 mod 109 ≡ 47
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 ≡ 232 × 394-1 (mod 523) ≡ 232 × 150 (mod 523) ≡ 282 (mod 523)
x ≡ 476 × 720-1 (mod 497) ≡ 476 × 419 (mod 497) ≡ 147 (mod 497)
x ≡ 611 × 276-1 (mod 109) ≡ 611 × 47 (mod 109) ≡ 50 (mod 109)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 523 × 497 × 109 = 28332479
  2. We calculate the numbers M1 to M3
    M1=M/m1=28332479/523=54173,   M2=M/m2=28332479/497=57007,   M3=M/m3=28332479/109=259931
  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
    523541730523010
    54173523103304101
    523304121901-1
    3042191851-12
    21985249-12-5
    85491362-57
    4936113-57-12
    36132107-1231
    131013-1231-43
    1033131-43160
    3130-43160-523
    So our multiplicative inverse is 160 mod 523 ≡ 160
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    497570070497010
    57007497114349101
    497349114801-1
    3491482531-13
    14853242-13-7
    53421113-710
    421139-710-37
    1191210-3747
    9241-3747-225
    212047-225497
    So our multiplicative inverse is -225 mod 497 ≡ 272
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1092599310109010
    259931109238475101
    1097513401-1
    7534271-13
    34746-13-13
    76113-1316
    6160-1316-109
    So our multiplicative inverse is 16 mod 109 ≡ 16
    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
    =  (282 × 54173 × 160 +
       147 × 57007 × 272 +
       50 × 259931 × 16)   mod 28332479
    = 1747102 (mod 28332479)


    So our answer is 1747102 (mod 28332479).


Verification

So we found that x ≡ 1747102
If this is correct, then the following statements (i.e. the original equations) are true:
394x (mod 523) ≡ 232 (mod 523)
720x (mod 497) ≡ 476 (mod 497)
276x (mod 109) ≡ 611 (mod 109)

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