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
6478530647010
8536471206101
64720632901-3
20629731-322
29392-322-201
321122-201223
2120-201223-647
So our multiplicative inverse is 223 mod 647 ≡ 223
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
817431138601-1
4313861451-12
38645826-12-17
45261192-1719
261917-1719-36
1972519-3691
7512-3691-127
522191-127345
2120-127345-817
So our multiplicative inverse is 345 mod 817 ≡ 345
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
897355218701-2
35518711681-23
187168119-23-5
168198163-543
191613-543-48
1635143-48283
3130-48283-897
So our multiplicative inverse is 283 mod 897 ≡ 283
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 ≡ 638 × 853-1 (mod 647) ≡ 638 × 223 (mod 647) ≡ 581 (mod 647)
x ≡ 146 × 431-1 (mod 817) ≡ 146 × 345 (mod 817) ≡ 533 (mod 817)
x ≡ 377 × 355-1 (mod 897) ≡ 377 × 283 (mod 897) ≡ 845 (mod 897)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 647 × 817 × 897 = 474153303
  2. We calculate the numbers M1 to M3
    M1=M/m1=474153303/647=732849,   M2=M/m2=474153303/817=580359,   M3=M/m3=474153303/897=528599
  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
    6477328490647010
    7328496471132445101
    647445120201-1
    4452022411-13
    20241438-13-13
    4138133-1316
    383122-1316-205
    321116-205221
    2120-205221-647
    So our multiplicative inverse is 221 mod 647 ≡ 221
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8175803590817010
    580359817710289101
    817289223901-2
    2892391501-23
    23950439-23-14
    50391113-1417
    391136-1417-65
    1161517-6582
    6511-6582-147
    515082-147817
    So our multiplicative inverse is -147 mod 817 ≡ 670
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8975285990897010
    528599897589266101
    89726639901-3
    266992681-37
    9968131-37-10
    6831267-1027
    31651-1027-145
    616027-145897
    So our multiplicative inverse is -145 mod 897 ≡ 752
    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
    =  (581 × 732849 × 221 +
       533 × 580359 × 670 +
       845 × 528599 × 752)   mod 474153303
    = 455609570 (mod 474153303)


    So our answer is 455609570 (mod 474153303).


Verification

So we found that x ≡ 455609570
If this is correct, then the following statements (i.e. the original equations) are true:
853x (mod 647) ≡ 638 (mod 647)
431x (mod 817) ≡ 146 (mod 817)
355x (mod 897) ≡ 377 (mod 897)

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