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
4135930413010
5934131180101
41318025301-2
180533211-27
5321211-27-16
21111107-1623
111011-1623-39
10110023-39413
So our multiplicative inverse is -39 mod 413 ≡ 374
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1074860107010
486107458101
1075814901-1
5849191-12
49954-12-11
94212-1124
4140-1124-107
So our multiplicative inverse is 24 mod 107 ≡ 24
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1493910149010
391149293101
1499315601-1
93561371-12
5637119-12-3
37191182-35
191811-35-8
1811805-8149
So our multiplicative inverse is -8 mod 149 ≡ 141
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 ≡ 876 × 593-1 (mod 413) ≡ 876 × 374 (mod 413) ≡ 115 (mod 413)
x ≡ 152 × 486-1 (mod 107) ≡ 152 × 24 (mod 107) ≡ 10 (mod 107)
x ≡ 650 × 391-1 (mod 149) ≡ 650 × 141 (mod 149) ≡ 15 (mod 149)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 413 × 107 × 149 = 6584459
  2. We calculate the numbers M1 to M3
    M1=M/m1=6584459/413=15943,   M2=M/m2=6584459/107=61537,   M3=M/m3=6584459/149=44191
  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
    413159430413010
    1594341338249101
    413249116401-1
    2491641851-12
    16485179-12-3
    8579162-35
    796131-35-68
    61605-68413
    So our multiplicative inverse is -68 mod 413 ≡ 345
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    107615370107010
    6153710757512101
    1071281101-8
    1211111-89
    111110-89-107
    So our multiplicative inverse is 9 mod 107 ≡ 9
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    149441910149010
    4419114929687101
    1498716201-1
    87621251-12
    6225212-12-5
    2512212-512
    121120-512-149
    So our multiplicative inverse is 12 mod 149 ≡ 12
    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
    =  (115 × 15943 × 345 +
       10 × 61537 × 9 +
       15 × 44191 × 12)   mod 6584459
    = 754253 (mod 6584459)


    So our answer is 754253 (mod 6584459).


Verification

So we found that x ≡ 754253
If this is correct, then the following statements (i.e. the original equations) are true:
593x (mod 413) ≡ 876 (mod 413)
486x (mod 107) ≡ 152 (mod 107)
391x (mod 149) ≡ 650 (mod 149)

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