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
1633100163010
3101631147101
16314711601-1
14716931-110
16351-110-51
313010-51163
So our multiplicative inverse is -51 mod 163 ≡ 112
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8772903701-3
29074131-3124
7321-3124-251
3130124-251877
So our multiplicative inverse is -251 mod 877 ≡ 626
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6637330663010
733663170101
6637093301-9
7033241-919
33481-919-161
414019-161663
So our multiplicative inverse is -161 mod 663 ≡ 502
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 ≡ 507 × 310-1 (mod 163) ≡ 507 × 112 (mod 163) ≡ 60 (mod 163)
x ≡ 521 × 290-1 (mod 877) ≡ 521 × 626 (mod 877) ≡ 779 (mod 877)
x ≡ 542 × 733-1 (mod 663) ≡ 542 × 502 (mod 663) ≡ 254 (mod 663)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 163 × 877 × 663 = 94776513
  2. We calculate the numbers M1 to M3
    M1=M/m1=94776513/163=581451,   M2=M/m2=94776513/877=108069,   M3=M/m3=94776513/663=142951
  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
    1635814510163010
    581451163356730101
    1633051301-5
    3013241-511
    13431-511-38
    414011-38163
    So our multiplicative inverse is -38 mod 163 ≡ 125
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8771080690877010
    108069877123198101
    87719848501-4
    198852281-49
    852831-49-31
    2812809-31877
    So our multiplicative inverse is -31 mod 877 ≡ 846
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6631429510663010
    142951663215406101
    663406125701-1
    40625711491-12
    2571491108-12-3
    1491081412-35
    10841226-35-13
    41261155-1318
    2615111-1318-31
    15111418-3149
    11423-3149-129
    431149-129178
    3130-129178-663
    So our multiplicative inverse is 178 mod 663 ≡ 178
    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
    =  (60 × 581451 × 125 +
       779 × 108069 × 846 +
       254 × 142951 × 178)   mod 94776513
    = 63444713 (mod 94776513)


    So our answer is 63444713 (mod 94776513).


Verification

So we found that x ≡ 63444713
If this is correct, then the following statements (i.e. the original equations) are true:
310x (mod 163) ≡ 507 (mod 163)
290x (mod 877) ≡ 521 (mod 877)
733x (mod 663) ≡ 542 (mod 663)

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