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
797430136701-1
4303671631-12
36763552-12-11
63521112-1113
521148-1113-63
1181313-6376
8322-6376-215
321176-215291
2120-215291-797
So our multiplicative inverse is 291 mod 797 ≡ 291
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
5117090511010
7095111198101
511198211501-2
1981151831-23
11583132-23-5
83322193-513
3219113-513-18
19131613-1831
13621-1831-80
616031-80511
So our multiplicative inverse is -80 mod 511 ≡ 431
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
6771352101-52
1311301-52677
So our multiplicative inverse is -52 mod 677 ≡ 625
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 ≡ 13 × 430-1 (mod 797) ≡ 13 × 291 (mod 797) ≡ 595 (mod 797)
x ≡ 306 × 709-1 (mod 511) ≡ 306 × 431 (mod 511) ≡ 48 (mod 511)
x ≡ 313 × 13-1 (mod 677) ≡ 313 × 625 (mod 677) ≡ 649 (mod 677)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 797 × 511 × 677 = 275719759
  2. We calculate the numbers M1 to M3
    M1=M/m1=275719759/797=345947,   M2=M/m2=275719759/511=539569,   M3=M/m3=275719759/677=407267
  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
    7973459470797010
    34594779743449101
    79749161301-16
    49133101-1649
    131013-1649-65
    1033149-65244
    3130-65244-797
    So our multiplicative inverse is 244 mod 797 ≡ 244
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5115395690511010
    5395695111055464101
    51146414701-1
    464479411-110
    474116-110-11
    4166510-1176
    6511-1176-87
    515076-87511
    So our multiplicative inverse is -87 mod 511 ≡ 424
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    6774072670677010
    407267677601390101
    677390128701-1
    39028711031-12
    287103281-12-5
    103811222-57
    8122315-57-26
    2215177-2633
    15721-2633-92
    717033-92677
    So our multiplicative inverse is -92 mod 677 ≡ 585
    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
    =  (595 × 345947 × 244 +
       48 × 539569 × 424 +
       649 × 407267 × 585)   mod 275719759
    = 218067765 (mod 275719759)


    So our answer is 218067765 (mod 275719759).


Verification

So we found that x ≡ 218067765
If this is correct, then the following statements (i.e. the original equations) are true:
430x (mod 797) ≡ 13 (mod 797)
709x (mod 511) ≡ 306 (mod 511)
13x (mod 677) ≡ 313 (mod 677)

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