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
331814701-4
8171141-445
7413-445-49
431145-4994
3130-4994-331
So our multiplicative inverse is 94 mod 331 ≡ 94
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5272622301-2
26238711-2175
3130-2175-527
So our multiplicative inverse is 175 mod 527 ≡ 175
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2243230224010
323224199101
2249922601-2
99263211-27
262115-27-9
215417-943
5150-943-224
So our multiplicative inverse is 43 mod 224 ≡ 43
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 ≡ 89 × 81-1 (mod 331) ≡ 89 × 94 (mod 331) ≡ 91 (mod 331)
x ≡ 205 × 262-1 (mod 527) ≡ 205 × 175 (mod 527) ≡ 39 (mod 527)
x ≡ 774 × 323-1 (mod 224) ≡ 774 × 43 (mod 224) ≡ 130 (mod 224)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 331 × 527 × 224 = 39073888
  2. We calculate the numbers M1 to M3
    M1=M/m1=39073888/331=118048,   M2=M/m2=39073888/527=74144,   M3=M/m3=39073888/224=174437
  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
    3311180480331010
    118048331356212101
    331212111901-1
    2121191931-12
    11993126-12-3
    93263152-311
    2615111-311-14
    15111411-1425
    11423-1425-64
    431125-6489
    3130-6489-331
    So our multiplicative inverse is 89 mod 331 ≡ 89
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    527741440527010
    74144527140364101
    527364116301-1
    3641632381-13
    16338411-13-13
    3811353-1342
    11521-1342-97
    515042-97527
    So our multiplicative inverse is -97 mod 527 ≡ 430
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2241744370224010
    174437224778165101
    22416515901-1
    165592471-13
    5947112-13-4
    47123113-415
    121111-415-19
    11111015-19224
    So our multiplicative inverse is -19 mod 224 ≡ 205
    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
    =  (91 × 118048 × 89 +
       39 × 74144 × 430 +
       130 × 174437 × 205)   mod 39073888
    = 10281282 (mod 39073888)


    So our answer is 10281282 (mod 39073888).


Verification

So we found that x ≡ 10281282
If this is correct, then the following statements (i.e. the original equations) are true:
81x (mod 331) ≡ 89 (mod 331)
262x (mod 527) ≡ 205 (mod 527)
323x (mod 224) ≡ 774 (mod 224)

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