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
3713631801-1
36384531-146
8322-146-93
321146-93139
2120-93139-371
So our multiplicative inverse is 139 mod 371 ≡ 139
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
653491116201-1
491162351-14
1625322-14-129
52214-129262
2120-129262-653
So our multiplicative inverse is 262 mod 653 ≡ 262
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
7469510746010
9517461205101
746205313101-3
2051311741-34
13174157-34-7
74571174-711
571736-711-40
1762511-4091
6511-4091-131
515091-131746
So our multiplicative inverse is -131 mod 746 ≡ 615
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 ≡ 471 × 363-1 (mod 371) ≡ 471 × 139 (mod 371) ≡ 173 (mod 371)
x ≡ 799 × 491-1 (mod 653) ≡ 799 × 262 (mod 653) ≡ 378 (mod 653)
x ≡ 717 × 951-1 (mod 746) ≡ 717 × 615 (mod 746) ≡ 69 (mod 746)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 371 × 653 × 746 = 180728198
  2. We calculate the numbers M1 to M3
    M1=M/m1=180728198/371=487138,   M2=M/m2=180728198/653=276766,   M3=M/m3=180728198/746=242263
  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
    3714871380371010
    487138371131315101
    37115241101-24
    1511141-2425
    11423-2425-74
    431125-7499
    3130-7499-371
    So our multiplicative inverse is 99 mod 371 ≡ 99
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6532767660653010
    276766653423547101
    653547110601-1
    5471065171-16
    1061764-16-37
    174416-37154
    4140-37154-653
    So our multiplicative inverse is 154 mod 653 ≡ 154
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7462422630746010
    242263746324559101
    746559118701-1
    55918721851-13
    18718512-13-4
    18529213-4371
    2120-4371-746
    So our multiplicative inverse is 371 mod 746 ≡ 371
    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
    =  (173 × 487138 × 99 +
       378 × 276766 × 154 +
       69 × 242263 × 371)   mod 180728198
    = 112939993 (mod 180728198)


    So our answer is 112939993 (mod 180728198).


Verification

So we found that x ≡ 112939993
If this is correct, then the following statements (i.e. the original equations) are true:
363x (mod 371) ≡ 471 (mod 371)
491x (mod 653) ≡ 799 (mod 653)
951x (mod 746) ≡ 717 (mod 746)

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