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
6598470659010
8476591188101
65918839501-3
188951931-34
959312-34-7
9324614-7326
2120-7326-659
So our multiplicative inverse is 326 mod 659 ≡ 326
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3593760359010
376359117101
3591721201-21
172811-21169
2120-21169-359
So our multiplicative inverse is 169 mod 359 ≡ 169
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4281528801-28
158171-2829
8711-2829-57
717029-57428
So our multiplicative inverse is -57 mod 428 ≡ 371
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 ≡ 444 × 847-1 (mod 659) ≡ 444 × 326 (mod 659) ≡ 423 (mod 659)
x ≡ 956 × 376-1 (mod 359) ≡ 956 × 169 (mod 359) ≡ 14 (mod 359)
x ≡ 771 × 15-1 (mod 428) ≡ 771 × 371 (mod 428) ≡ 137 (mod 428)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 659 × 359 × 428 = 101256668
  2. We calculate the numbers M1 to M3
    M1=M/m1=101256668/659=153652,   M2=M/m2=101256668/359=282052,   M3=M/m3=101256668/428=236581
  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
    6591536520659010
    153652659233105101
    65910562901-6
    105293181-619
    2918111-619-25
    18111719-2544
    11714-2544-69
    741344-69113
    4311-69113-182
    3130113-182659
    So our multiplicative inverse is -182 mod 659 ≡ 477
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    3592820520359010
    282052359785237101
    359237112201-1
    23712211151-12
    12211517-12-3
    11571632-350
    7321-350-103
    313050-103359
    So our multiplicative inverse is -103 mod 359 ≡ 256
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4282365810428010
    236581428552325101
    428325110301-1
    3251033161-14
    1031667-14-25
    167224-2554
    7231-2554-187
    212054-187428
    So our multiplicative inverse is -187 mod 428 ≡ 241
    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
    =  (423 × 153652 × 477 +
       14 × 282052 × 256 +
       137 × 236581 × 241)   mod 101256668
    = 30716413 (mod 101256668)


    So our answer is 30716413 (mod 101256668).


Verification

So we found that x ≡ 30716413
If this is correct, then the following statements (i.e. the original equations) are true:
847x (mod 659) ≡ 444 (mod 659)
376x (mod 359) ≡ 956 (mod 359)
15x (mod 428) ≡ 771 (mod 428)

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