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
2637420263010
7422632216101
26321614701-1
216474281-15
4728119-15-6
2819195-611
19921-611-28
919011-28263
So our multiplicative inverse is -28 mod 263 ≡ 235
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
89684914701-1
849471831-119
473152-119-286
321119-286305
2120-286305-896
So our multiplicative inverse is 305 mod 896 ≡ 305
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
839333217301-2
33317311601-23
173160113-23-5
160131243-563
13431-563-194
414063-194839
So our multiplicative inverse is -194 mod 839 ≡ 645
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 ≡ 443 × 742-1 (mod 263) ≡ 443 × 235 (mod 263) ≡ 220 (mod 263)
x ≡ 552 × 849-1 (mod 896) ≡ 552 × 305 (mod 896) ≡ 808 (mod 896)
x ≡ 397 × 333-1 (mod 839) ≡ 397 × 645 (mod 839) ≡ 170 (mod 839)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 263 × 896 × 839 = 197708672
  2. We calculate the numbers M1 to M3
    M1=M/m1=197708672/263=751744,   M2=M/m2=197708672/896=220657,   M3=M/m3=197708672/839=235648
  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
    2637517440263010
    751744263285890101
    2639028301-2
    9083171-23
    837116-23-35
    76113-3538
    6160-3538-263
    So our multiplicative inverse is 38 mod 263 ≡ 38
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8962206570896010
    220657896246241101
    896241317301-3
    2411731681-34
    17368237-34-11
    68371314-1115
    373116-1115-26
    3165115-26145
    6160-26145-896
    So our multiplicative inverse is 145 mod 896 ≡ 145
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8392356480839010
    235648839280728101
    839728111101-1
    7281116621-17
    11162149-17-8
    62491137-815
    4913310-815-53
    13101315-5368
    10331-5368-257
    313068-257839
    So our multiplicative inverse is -257 mod 839 ≡ 582
    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
    =  (220 × 751744 × 38 +
       808 × 220657 × 145 +
       170 × 235648 × 582)   mod 197708672
    = 93338920 (mod 197708672)


    So our answer is 93338920 (mod 197708672).


Verification

So we found that x ≡ 93338920
If this is correct, then the following statements (i.e. the original equations) are true:
742x (mod 263) ≡ 443 (mod 263)
849x (mod 896) ≡ 552 (mod 896)
333x (mod 839) ≡ 397 (mod 839)

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