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
347215113201-1
2151321831-12
13283149-12-3
83491342-35
4934115-35-8
3415245-821
15433-821-71
431121-7192
3130-7192-347
So our multiplicative inverse is 92 mod 347 ≡ 92
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
943206411901-4
2061191871-45
11987132-45-9
87322235-923
322319-923-32
2392523-3287
9514-3287-119
541187-119206
4140-119206-943
So our multiplicative inverse is 206 mod 943 ≡ 206
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8278930827010
893827166101
82766123501-12
66351311-1213
353114-1213-25
3147313-25188
4311-25188-213
3130188-213827
So our multiplicative inverse is -213 mod 827 ≡ 614
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 ≡ 446 × 215-1 (mod 347) ≡ 446 × 92 (mod 347) ≡ 86 (mod 347)
x ≡ 229 × 206-1 (mod 943) ≡ 229 × 206 (mod 943) ≡ 24 (mod 943)
x ≡ 192 × 893-1 (mod 827) ≡ 192 × 614 (mod 827) ≡ 454 (mod 827)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 347 × 943 × 827 = 270611767
  2. We calculate the numbers M1 to M3
    M1=M/m1=270611767/347=779861,   M2=M/m2=270611767/943=286969,   M3=M/m3=270611767/827=327221
  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
    3477798610347010
    7798613472247152101
    34715224301-2
    152433231-27
    4323120-27-9
    2320137-916
    20362-916-105
    321116-105121
    2120-105121-347
    So our multiplicative inverse is 121 mod 347 ≡ 121
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9432869690943010
    286969943304297101
    94329735201-3
    297525371-316
    5237115-316-19
    37152716-1954
    15721-1954-127
    717054-127943
    So our multiplicative inverse is -127 mod 943 ≡ 816
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8273272210827010
    327221827395556101
    827556127101-1
    5562712141-13
    27114195-13-58
    145243-58119
    5411-58119-177
    4140119-177827
    So our multiplicative inverse is -177 mod 827 ≡ 650
    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
    =  (86 × 779861 × 121 +
       24 × 286969 × 816 +
       454 × 327221 × 650)   mod 270611767
    = 159162393 (mod 270611767)


    So our answer is 159162393 (mod 270611767).


Verification

So we found that x ≡ 159162393
If this is correct, then the following statements (i.e. the original equations) are true:
215x (mod 347) ≡ 446 (mod 347)
206x (mod 943) ≡ 229 (mod 943)
893x (mod 827) ≡ 192 (mod 827)

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