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
17855017010
85517505101
1753201-3
52211-37
2120-37-17
So our multiplicative inverse is 7 mod 17 ≡ 7
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
73957125501-12
5755121-1213
552271-1213-363
212013-363739
So our multiplicative inverse is -363 mod 739 ≡ 376
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3796470379010
6473791268101
379268111101-1
2681112461-13
11146219-13-7
4619283-717
19823-717-41
832217-4199
3211-4199-140
212099-140379
So our multiplicative inverse is -140 mod 379 ≡ 239
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 ≡ 173 × 855-1 (mod 17) ≡ 173 × 7 (mod 17) ≡ 4 (mod 17)
x ≡ 783 × 57-1 (mod 739) ≡ 783 × 376 (mod 739) ≡ 286 (mod 739)
x ≡ 313 × 647-1 (mod 379) ≡ 313 × 239 (mod 379) ≡ 144 (mod 379)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 17 × 739 × 379 = 4761377
  2. We calculate the numbers M1 to M3
    M1=M/m1=4761377/17=280081,   M2=M/m2=4761377/739=6443,   M3=M/m3=4761377/379=12563
  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
    17280081017010
    28008117164756101
    1762501-2
    65111-23
    5150-23-17
    So our multiplicative inverse is 3 mod 17 ≡ 3
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    73964430739010
    64437398531101
    739531120801-1
    53120821151-13
    208115193-13-4
    115931223-47
    932245-47-32
    225427-32135
    5221-32135-302
    2120135-302739
    So our multiplicative inverse is -302 mod 739 ≡ 437
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    379125630379010
    125633793356101
    3795664301-6
    56431131-67
    431334-67-27
    134317-2788
    4140-2788-379
    So our multiplicative inverse is 88 mod 379 ≡ 88
    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
    =  (4 × 280081 × 3 +
       286 × 6443 × 437 +
       144 × 12563 × 88)   mod 4761377
    = 1258803 (mod 4761377)


    So our answer is 1258803 (mod 4761377).


Verification

So we found that x ≡ 1258803
If this is correct, then the following statements (i.e. the original equations) are true:
855x (mod 17) ≡ 173 (mod 17)
57x (mod 739) ≡ 783 (mod 739)
647x (mod 379) ≡ 313 (mod 379)

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