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
7978196801-9
81681131-910
681353-910-59
1334110-59246
3130-59246-797
So our multiplicative inverse is 246 mod 797 ≡ 246
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
833666116701-1
66616731651-14
16716512-14-5
16528214-5414
2120-5414-833
So our multiplicative inverse is 414 mod 833 ≡ 414
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3794370379010
437379158101
3795863101-6
58311271-67
312714-67-13
274637-1385
4311-1385-98
313085-98379
So our multiplicative inverse is -98 mod 379 ≡ 281
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 ≡ 887 × 81-1 (mod 797) ≡ 887 × 246 (mod 797) ≡ 621 (mod 797)
x ≡ 22 × 666-1 (mod 833) ≡ 22 × 414 (mod 833) ≡ 778 (mod 833)
x ≡ 258 × 437-1 (mod 379) ≡ 258 × 281 (mod 379) ≡ 109 (mod 379)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 797 × 833 × 379 = 251618479
  2. We calculate the numbers M1 to M3
    M1=M/m1=251618479/797=315707,   M2=M/m2=251618479/833=302063,   M3=M/m3=251618479/379=663901
  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
    7973157070797010
    31570779739695101
    7979583701-8
    95372211-817
    3721116-817-25
    21161517-2542
    16531-2542-151
    515042-151797
    So our multiplicative inverse is -151 mod 797 ≡ 646
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8333020630833010
    302063833362517101
    833517131601-1
    51731612011-12
    3162011115-12-3
    2011151862-35
    11586129-35-8
    86292285-821
    292811-821-29
    28128021-29833
    So our multiplicative inverse is -29 mod 833 ≡ 804
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3796639010379010
    6639013791751272101
    379272110701-1
    2721072581-13
    10758149-13-4
    5849193-47
    49954-47-39
    94217-3985
    4140-3985-379
    So our multiplicative inverse is 85 mod 379 ≡ 85
    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
    =  (621 × 315707 × 646 +
       778 × 302063 × 804 +
       109 × 663901 × 85)   mod 251618479
    = 177572221 (mod 251618479)


    So our answer is 177572221 (mod 251618479).


Verification

So we found that x ≡ 177572221
If this is correct, then the following statements (i.e. the original equations) are true:
81x (mod 797) ≡ 887 (mod 797)
666x (mod 833) ≡ 22 (mod 833)
437x (mod 379) ≡ 258 (mod 379)

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