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
1998100199010
810199414101
1991414301-14
143421-1457
3211-1457-71
212057-71199
So our multiplicative inverse is -71 mod 199 ≡ 128
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
997648134901-1
64834912991-12
349299150-12-3
299505492-317
504911-317-20
49149017-20997
So our multiplicative inverse is -20 mod 997 ≡ 977
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
229545401-45
54111-4546
4140-4546-229
So our multiplicative inverse is 46 mod 229 ≡ 46
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 ≡ 951 × 810-1 (mod 199) ≡ 951 × 128 (mod 199) ≡ 139 (mod 199)
x ≡ 247 × 648-1 (mod 997) ≡ 247 × 977 (mod 997) ≡ 45 (mod 997)
x ≡ 480 × 5-1 (mod 229) ≡ 480 × 46 (mod 229) ≡ 96 (mod 229)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 199 × 997 × 229 = 45434287
  2. We calculate the numbers M1 to M3
    M1=M/m1=45434287/199=228313,   M2=M/m2=45434287/997=45571,   M3=M/m3=45434287/229=198403
  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
    1992283130199010
    228313199114760101
    1996031901-3
    6019331-310
    19361-310-63
    313010-63199
    So our multiplicative inverse is -63 mod 199 ≡ 136
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    997455710997010
    4557199745706101
    997706129101-1
    70629121241-13
    291124243-13-7
    124432383-717
    433815-717-24
    3857317-24185
    5312-24185-209
    3211185-209394
    2120-209394-997
    So our multiplicative inverse is 394 mod 997 ≡ 394
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2291984030229010
    19840322986689101
    2298925101-2
    89511381-23
    5138113-23-5
    38132123-513
    131211-513-18
    12112013-18229
    So our multiplicative inverse is -18 mod 229 ≡ 211
    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
    =  (139 × 228313 × 136 +
       45 × 45571 × 394 +
       96 × 198403 × 211)   mod 45434287
    = 10562263 (mod 45434287)


    So our answer is 10562263 (mod 45434287).


Verification

So we found that x ≡ 10562263
If this is correct, then the following statements (i.e. the original equations) are true:
810x (mod 199) ≡ 951 (mod 199)
648x (mod 997) ≡ 247 (mod 997)
5x (mod 229) ≡ 480 (mod 229)

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