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
966523144301-1
5234431801-12
44380543-12-11
80431372-1113
433716-1113-24
3766113-24157
6160-24157-966
So our multiplicative inverse is 157 mod 966 ≡ 157
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4915730491010
573491182101
4918258101-5
8281111-56
811810-56-491
So our multiplicative inverse is 6 mod 491 ≡ 6
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4154570415010
457415142101
4154293701-9
4237151-910
37572-910-79
522110-79168
2120-79168-415
So our multiplicative inverse is 168 mod 415 ≡ 168
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 ≡ 721 × 523-1 (mod 966) ≡ 721 × 157 (mod 966) ≡ 175 (mod 966)
x ≡ 912 × 573-1 (mod 491) ≡ 912 × 6 (mod 491) ≡ 71 (mod 491)
x ≡ 588 × 457-1 (mod 415) ≡ 588 × 168 (mod 415) ≡ 14 (mod 415)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 966 × 491 × 415 = 196836990
  2. We calculate the numbers M1 to M3
    M1=M/m1=196836990/966=203765,   M2=M/m2=196836990/491=400890,   M3=M/m3=196836990/415=474306
  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
    9662037650966010
    203765966210905101
    96690516101-1
    9056114511-115
    6151110-115-16
    51105115-1695
    101100-1695-966
    So our multiplicative inverse is 95 mod 966 ≡ 95
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4914008900491010
    400890491816234101
    49123422301-2
    234231041-221
    23453-221-107
    431121-107128
    3130-107128-491
    So our multiplicative inverse is 128 mod 491 ≡ 128
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4154743060415010
    4743064151142376101
    41537613901-1
    376399251-110
    3925114-110-11
    251411110-1121
    141113-1121-32
    1133221-32117
    3211-32117-149
    2120117-149415
    So our multiplicative inverse is -149 mod 415 ≡ 266
    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
    =  (175 × 203765 × 95 +
       71 × 400890 × 128 +
       14 × 474306 × 266)   mod 196836990
    = 136369429 (mod 196836990)


    So our answer is 136369429 (mod 196836990).


Verification

So we found that x ≡ 136369429
If this is correct, then the following statements (i.e. the original equations) are true:
523x (mod 966) ≡ 721 (mod 966)
573x (mod 491) ≡ 912 (mod 491)
457x (mod 415) ≡ 588 (mod 415)

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