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
98589618901-1
896891061-111
896145-111-155
651111-155166
5150-155166-985
So our multiplicative inverse is 166 mod 985 ≡ 166
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
77365115801-11
6558171-1112
58782-1112-107
723112-107333
2120-107333-773
So our multiplicative inverse is 333 mod 773 ≡ 333
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
829602122701-1
60222721481-13
227148179-13-4
148791693-47
7969110-47-11
6910697-1173
10911-1173-84
919073-84829
So our multiplicative inverse is -84 mod 829 ≡ 745
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 ≡ 47 × 896-1 (mod 985) ≡ 47 × 166 (mod 985) ≡ 907 (mod 985)
x ≡ 690 × 65-1 (mod 773) ≡ 690 × 333 (mod 773) ≡ 189 (mod 773)
x ≡ 214 × 602-1 (mod 829) ≡ 214 × 745 (mod 829) ≡ 262 (mod 829)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 985 × 773 × 829 = 631204745
  2. We calculate the numbers M1 to M3
    M1=M/m1=631204745/985=640817,   M2=M/m2=631204745/773=816565,   M3=M/m3=631204745/829=761405
  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
    9856408170985010
    640817985650567101
    985567141801-1
    56741811491-12
    4181492120-12-5
    1491201292-57
    1202944-57-33
    294717-33238
    4140-33238-985
    So our multiplicative inverse is 238 mod 985 ≡ 238
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7738165650773010
    8165657731056277101
    773277221901-2
    2772191581-23
    21958345-23-11
    58451133-1114
    451336-1114-53
    1362114-53120
    6160-53120-773
    So our multiplicative inverse is 120 mod 773 ≡ 120
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8297614050829010
    761405829918383101
    82938326301-2
    38363651-213
    635123-213-158
    531213-158171
    3211-158171-329
    2120171-329829
    So our multiplicative inverse is -329 mod 829 ≡ 500
    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
    =  (907 × 640817 × 238 +
       189 × 816565 × 120 +
       262 × 761405 × 500)   mod 631204745
    = 325225252 (mod 631204745)


    So our answer is 325225252 (mod 631204745).


Verification

So we found that x ≡ 325225252
If this is correct, then the following statements (i.e. the original equations) are true:
896x (mod 985) ≡ 47 (mod 985)
65x (mod 773) ≡ 690 (mod 773)
602x (mod 829) ≡ 214 (mod 829)

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