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
633523111001-1
5231104831-15
11083127-15-6
8327325-623
272131-623-305
212023-305633
So our multiplicative inverse is -305 mod 633 ≡ 328
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8547112201-12
7123511-12421
2120-12421-854
So our multiplicative inverse is 421 mod 854 ≡ 421
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1671791401-9
1714131-910
14342-910-49
321110-4959
2120-4959-167
So our multiplicative inverse is 59 mod 167 ≡ 59
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 ≡ 28 × 523-1 (mod 633) ≡ 28 × 328 (mod 633) ≡ 322 (mod 633)
x ≡ 391 × 71-1 (mod 854) ≡ 391 × 421 (mod 854) ≡ 643 (mod 854)
x ≡ 940 × 17-1 (mod 167) ≡ 940 × 59 (mod 167) ≡ 16 (mod 167)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 633 × 854 × 167 = 90277194
  2. We calculate the numbers M1 to M3
    M1=M/m1=90277194/633=142618,   M2=M/m2=90277194/854=105711,   M3=M/m3=90277194/167=540582
  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
    6331426180633010
    142618633225193101
    63319335401-3
    193543311-310
    5431123-310-13
    31231810-1323
    23827-1323-59
    871123-5982
    7170-5982-633
    So our multiplicative inverse is 82 mod 633 ≡ 82
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8541057110854010
    105711854123669101
    854669118501-1
    66918531141-14
    185114171-14-5
    114711434-59
    7143128-59-14
    43281159-1423
    2815113-1423-37
    15131223-3760
    13261-3760-397
    212060-397854
    So our multiplicative inverse is -397 mod 854 ≡ 457
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1675405820167010
    54058216732373101
    167355201-55
    32111-5556
    2120-5556-167
    So our multiplicative inverse is 56 mod 167 ≡ 56
    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
    =  (322 × 142618 × 82 +
       643 × 105711 × 457 +
       16 × 540582 × 56)   mod 90277194
    = 14947351 (mod 90277194)


    So our answer is 14947351 (mod 90277194).


Verification

So we found that x ≡ 14947351
If this is correct, then the following statements (i.e. the original equations) are true:
523x (mod 633) ≡ 28 (mod 633)
71x (mod 854) ≡ 391 (mod 854)
17x (mod 167) ≡ 940 (mod 167)

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