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
7979920797010
9927971195101
79719541701-4
195171181-445
17821-445-94
818045-94797
So our multiplicative inverse is -94 mod 797 ≡ 703
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
439227121201-1
2272121151-12
21215142-12-29
152712-29205
2120-29205-439
So our multiplicative inverse is 205 mod 439 ≡ 205
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
647452119501-1
4521952621-13
1956239-13-10
629683-1063
9811-1063-73
818063-73647
So our multiplicative inverse is -73 mod 647 ≡ 574
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 ≡ 519 × 992-1 (mod 797) ≡ 519 × 703 (mod 797) ≡ 628 (mod 797)
x ≡ 329 × 227-1 (mod 439) ≡ 329 × 205 (mod 439) ≡ 278 (mod 439)
x ≡ 764 × 452-1 (mod 647) ≡ 764 × 574 (mod 647) ≡ 517 (mod 647)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 797 × 439 × 647 = 226374301
  2. We calculate the numbers M1 to M3
    M1=M/m1=226374301/797=284033,   M2=M/m2=226374301/439=515659,   M3=M/m3=226374301/647=349883
  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
    7972840330797010
    284033797356301101
    797301219501-2
    30119511061-23
    195106189-23-5
    106891173-58
    891754-58-45
    174418-45188
    4140-45188-797
    So our multiplicative inverse is 188 mod 797 ≡ 188
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4395156590439010
    5156594391174273101
    439273116601-1
    27316611071-12
    166107159-12-3
    107591482-35
    5948111-35-8
    4811445-837
    11423-837-82
    431137-82119
    3130-82119-439
    So our multiplicative inverse is 119 mod 439 ≡ 119
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6473498830647010
    349883647540503101
    647503114401-1
    5031443711-14
    1447122-14-9
    7123514-9319
    2120-9319-647
    So our multiplicative inverse is 319 mod 647 ≡ 319
    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
    =  (628 × 284033 × 188 +
       278 × 515659 × 119 +
       517 × 349883 × 319)   mod 226374301
    = 89941281 (mod 226374301)


    So our answer is 89941281 (mod 226374301).


Verification

So we found that x ≡ 89941281
If this is correct, then the following statements (i.e. the original equations) are true:
992x (mod 797) ≡ 519 (mod 797)
227x (mod 439) ≡ 329 (mod 439)
452x (mod 647) ≡ 764 (mod 647)

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