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
83954152901-15
54291251-1516
292514-1516-31
2546116-31202
4140-31202-839
So our multiplicative inverse is 202 mod 839 ≡ 202
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
757651110601-1
6511066151-17
1061571-17-50
1511507-50757
So our multiplicative inverse is -50 mod 757 ≡ 707
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
907323226101-2
3232611621-23
26162413-23-14
62134103-1459
131013-1459-73
1033159-73278
3130-73278-907
So our multiplicative inverse is 278 mod 907 ≡ 278
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 ≡ 661 × 54-1 (mod 839) ≡ 661 × 202 (mod 839) ≡ 121 (mod 839)
x ≡ 762 × 651-1 (mod 757) ≡ 762 × 707 (mod 757) ≡ 507 (mod 757)
x ≡ 235 × 323-1 (mod 907) ≡ 235 × 278 (mod 907) ≡ 26 (mod 907)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 839 × 757 × 907 = 576056561
  2. We calculate the numbers M1 to M3
    M1=M/m1=576056561/839=686599,   M2=M/m2=576056561/757=760973,   M3=M/m3=576056561/907=635123
  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
    8396865990839010
    686599839818297101
    839297224501-2
    2972451521-23
    24552437-23-14
    52371153-1417
    371527-1417-48
    1572117-48113
    7170-48113-839
    So our multiplicative inverse is 113 mod 839 ≡ 113
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7577609730757010
    7609737571005188101
    7571884501-4
    18853731-4149
    5312-4149-153
    3211149-153302
    2120-153302-757
    So our multiplicative inverse is 302 mod 757 ≡ 302
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9076351230907010
    635123907700223101
    90722341501-4
    2231514131-457
    151312-457-61
    1326157-61423
    2120-61423-907
    So our multiplicative inverse is 423 mod 907 ≡ 423
    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
    =  (121 × 686599 × 113 +
       507 × 760973 × 302 +
       26 × 635123 × 423)   mod 576056561
    = 395561773 (mod 576056561)


    So our answer is 395561773 (mod 576056561).


Verification

So we found that x ≡ 395561773
If this is correct, then the following statements (i.e. the original equations) are true:
54x (mod 839) ≡ 661 (mod 839)
651x (mod 757) ≡ 762 (mod 757)
323x (mod 907) ≡ 235 (mod 907)

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