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
2239180223010
918223426101
2232681501-8
26151111-89
151114-89-17
114239-1743
4311-1743-60
313043-60223
So our multiplicative inverse is -60 mod 223 ≡ 163
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
53547615901-1
47659841-19
594143-19-127
43119-127136
3130-127136-535
So our multiplicative inverse is 136 mod 535 ≡ 136
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
989271317601-3
2711761951-34
17695181-34-7
95811144-711
8114511-711-62
14111311-6273
11332-6273-281
321173-281354
2120-281354-989
So our multiplicative inverse is 354 mod 989 ≡ 354
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 ≡ 190 × 918-1 (mod 223) ≡ 190 × 163 (mod 223) ≡ 196 (mod 223)
x ≡ 8 × 476-1 (mod 535) ≡ 8 × 136 (mod 535) ≡ 18 (mod 535)
x ≡ 733 × 271-1 (mod 989) ≡ 733 × 354 (mod 989) ≡ 364 (mod 989)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 223 × 535 × 989 = 117992645
  2. We calculate the numbers M1 to M3
    M1=M/m1=117992645/223=529115,   M2=M/m2=117992645/535=220547,   M3=M/m3=117992645/989=119305
  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
    2235291150223010
    5291152232372159101
    22315916401-1
    159642311-13
    643122-13-7
    3121513-7108
    2120-7108-223
    So our multiplicative inverse is 108 mod 223 ≡ 108
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5352205470535010
    220547535412127101
    53512742701-4
    127274191-417
    271918-417-21
    1982317-2159
    8322-2159-139
    321159-139198
    2120-139198-535
    So our multiplicative inverse is 198 mod 535 ≡ 198
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9891193050989010
    119305989120625101
    989625136401-1
    62536412611-12
    3642611103-12-3
    2611032552-38
    10355148-38-11
    5548178-1119
    48766-1119-125
    761119-125144
    6160-125144-989
    So our multiplicative inverse is 144 mod 989 ≡ 144
    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
    =  (196 × 529115 × 108 +
       18 × 220547 × 198 +
       364 × 119305 × 144)   mod 117992645
    = 68959378 (mod 117992645)


    So our answer is 68959378 (mod 117992645).


Verification

So we found that x ≡ 68959378
If this is correct, then the following statements (i.e. the original equations) are true:
918x (mod 223) ≡ 190 (mod 223)
476x (mod 535) ≡ 8 (mod 535)
271x (mod 989) ≡ 733 (mod 989)

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