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
3839850383010
9853832219101
383219116401-1
2191641551-12
16455254-12-5
5554112-57
541540-57-383
So our multiplicative inverse is 7 mod 383 ≡ 7
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4496460449010
6464491197101
44919725501-2
197553321-27
5532123-27-9
3223197-916
23925-916-41
951416-4157
5411-4157-98
414057-98449
So our multiplicative inverse is -98 mod 449 ≡ 351
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
847234314501-3
2341451891-34
14589156-34-7
89561334-711
5633123-711-18
332311011-1829
231023-1829-76
1033129-76257
3130-76257-847
So our multiplicative inverse is 257 mod 847 ≡ 257
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 ≡ 404 × 985-1 (mod 383) ≡ 404 × 7 (mod 383) ≡ 147 (mod 383)
x ≡ 697 × 646-1 (mod 449) ≡ 697 × 351 (mod 449) ≡ 391 (mod 449)
x ≡ 698 × 234-1 (mod 847) ≡ 698 × 257 (mod 847) ≡ 669 (mod 847)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 383 × 449 × 847 = 145656049
  2. We calculate the numbers M1 to M3
    M1=M/m1=145656049/383=380303,   M2=M/m2=145656049/449=324401,   M3=M/m3=145656049/847=171967
  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
    3833803030383010
    380303383992367101
    38336711601-1
    3671622151-123
    161511-123-24
    15115023-24383
    So our multiplicative inverse is -24 mod 383 ≡ 359
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4493244010449010
    324401449722223101
    4492232301-2
    22337411-2149
    3130-2149-449
    So our multiplicative inverse is 149 mod 449 ≡ 149
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8471719670847010
    17196784720326101
    84726321501-32
    26151111-3233
    151114-3233-65
    1142333-65163
    4311-65163-228
    3130163-228847
    So our multiplicative inverse is -228 mod 847 ≡ 619
    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
    =  (147 × 380303 × 359 +
       391 × 324401 × 149 +
       669 × 171967 × 619)   mod 145656049
    = 66461371 (mod 145656049)


    So our answer is 66461371 (mod 145656049).


Verification

So we found that x ≡ 66461371
If this is correct, then the following statements (i.e. the original equations) are true:
985x (mod 383) ≡ 404 (mod 383)
646x (mod 449) ≡ 697 (mod 449)
234x (mod 847) ≡ 698 (mod 847)

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