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
1392760139010
2761391137101
1391371201-1
13726811-169
2120-169-139
So our multiplicative inverse is 69 mod 139 ≡ 69
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
895559133601-1
55933612231-12
3362231113-12-3
22311311102-35
11311013-35-8
11033625-8293
3211-8293-301
2120293-301895
So our multiplicative inverse is -301 mod 895 ≡ 594
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
979730124901-1
73024922321-13
249232117-13-4
2321713113-455
171116-455-59
1161555-59114
6511-59114-173
5150114-173979
So our multiplicative inverse is -173 mod 979 ≡ 806
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 ≡ 274 × 276-1 (mod 139) ≡ 274 × 69 (mod 139) ≡ 2 (mod 139)
x ≡ 710 × 559-1 (mod 895) ≡ 710 × 594 (mod 895) ≡ 195 (mod 895)
x ≡ 174 × 730-1 (mod 979) ≡ 174 × 806 (mod 979) ≡ 247 (mod 979)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 139 × 895 × 979 = 121792495
  2. We calculate the numbers M1 to M3
    M1=M/m1=121792495/139=876205,   M2=M/m2=121792495/895=136081,   M3=M/m3=121792495/979=124405
  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
    1398762050139010
    876205139630388101
    1398815101-1
    88511371-12
    5137114-12-3
    3714292-38
    14915-38-11
    95148-1119
    5411-1119-30
    414019-30139
    So our multiplicative inverse is -30 mod 139 ≡ 109
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8951360810895010
    13608189515241101
    89541213401-21
    4134171-2122
    34746-2122-109
    761122-109131
    6160-109131-895
    So our multiplicative inverse is 131 mod 895 ≡ 131
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9791244050979010
    12440597912772101
    97972134301-13
    72431291-1314
    4329114-1314-27
    29142114-2768
    141140-2768-979
    So our multiplicative inverse is 68 mod 979 ≡ 68
    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
    =  (2 × 876205 × 109 +
       195 × 136081 × 131 +
       247 × 124405 × 68)   mod 121792495
    = 32460950 (mod 121792495)


    So our answer is 32460950 (mod 121792495).


Verification

So we found that x ≡ 32460950
If this is correct, then the following statements (i.e. the original equations) are true:
276x (mod 139) ≡ 274 (mod 139)
559x (mod 895) ≡ 710 (mod 895)
730x (mod 979) ≡ 174 (mod 979)

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