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
1993660199010
3661991167101
19916713201-1
16732571-16
32744-16-25
74136-2531
4311-2531-56
313031-56199
So our multiplicative inverse is -56 mod 199 ≡ 143
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
997287313601-3
2871362151-37
1361591-37-66
1511507-66997
So our multiplicative inverse is -66 mod 997 ≡ 931
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8118810811010
881811170101
81170114101-11
70411291-1112
4129112-1112-23
29122512-2358
12522-2358-139
522158-139336
2120-139336-811
So our multiplicative inverse is 336 mod 811 ≡ 336
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 ≡ 783 × 366-1 (mod 199) ≡ 783 × 143 (mod 199) ≡ 131 (mod 199)
x ≡ 324 × 287-1 (mod 997) ≡ 324 × 931 (mod 997) ≡ 550 (mod 997)
x ≡ 859 × 881-1 (mod 811) ≡ 859 × 336 (mod 811) ≡ 719 (mod 811)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 199 × 997 × 811 = 160904833
  2. We calculate the numbers M1 to M3
    M1=M/m1=160904833/199=808567,   M2=M/m2=160904833/997=161389,   M3=M/m3=160904833/811=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
    1998085670199010
    808567199406330101
    1993061901-6
    30191111-67
    191118-67-13
    118137-1320
    8322-1320-53
    321120-5373
    2120-5373-199
    So our multiplicative inverse is 73 mod 199 ≡ 73
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9971613890997010
    161389997161872101
    997872112501-1
    87212561221-17
    12512213-17-8
    12234027-8327
    3211-8327-335
    2120327-335997
    So our multiplicative inverse is -335 mod 997 ≡ 662
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8111984030811010
    198403811244519101
    811519129201-1
    51929212271-12
    292227165-12-3
    227653322-311
    653221-311-25
    32132011-25811
    So our multiplicative inverse is -25 mod 811 ≡ 786
    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
    =  (131 × 808567 × 73 +
       550 × 161389 × 662 +
       719 × 198403 × 786)   mod 160904833
    = 13977493 (mod 160904833)


    So our answer is 13977493 (mod 160904833).


Verification

So we found that x ≡ 13977493
If this is correct, then the following statements (i.e. the original equations) are true:
366x (mod 199) ≡ 783 (mod 199)
287x (mod 997) ≡ 324 (mod 997)
881x (mod 811) ≡ 859 (mod 811)

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