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
667367130001-1
3673001671-12
30067432-12-9
6732232-920
323102-920-209
321120-209229
2120-209229-667
So our multiplicative inverse is 229 mod 667 ≡ 229
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
941369220301-2
36920311661-23
203166137-23-5
166374183-523
371821-523-51
18118023-51941
So our multiplicative inverse is -51 mod 941 ≡ 890
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
769590117901-1
5901793531-14
17953320-14-13
53202134-1330
201317-1330-43
1371630-4373
7611-4373-116
616073-116769
So our multiplicative inverse is -116 mod 769 ≡ 653
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 ≡ 579 × 367-1 (mod 667) ≡ 579 × 229 (mod 667) ≡ 525 (mod 667)
x ≡ 208 × 369-1 (mod 941) ≡ 208 × 890 (mod 941) ≡ 684 (mod 941)
x ≡ 574 × 590-1 (mod 769) ≡ 574 × 653 (mod 769) ≡ 319 (mod 769)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 667 × 941 × 769 = 482660543
  2. We calculate the numbers M1 to M3
    M1=M/m1=482660543/667=723629,   M2=M/m2=482660543/941=512923,   M3=M/m3=482660543/769=627647
  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
    6677236290667010
    7236296671084601101
    66760116601-1
    60166971-110
    66793-110-91
    732110-91192
    3130-91192-667
    So our multiplicative inverse is 192 mod 667 ≡ 192
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9415129230941010
    51292394154578101
    9417812501-12
    7851531-12181
    5312-12181-193
    3211181-193374
    2120-193374-941
    So our multiplicative inverse is 374 mod 941 ≡ 374
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    7696276470769010
    627647769816143101
    76914355401-5
    143542351-511
    5435119-511-16
    351911611-1627
    191613-1627-43
    1635127-43242
    3130-43242-769
    So our multiplicative inverse is 242 mod 769 ≡ 242
    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
    =  (525 × 723629 × 192 +
       684 × 512923 × 374 +
       319 × 627647 × 242)   mod 482660543
    = 177342485 (mod 482660543)


    So our answer is 177342485 (mod 482660543).


Verification

So we found that x ≡ 177342485
If this is correct, then the following statements (i.e. the original equations) are true:
367x (mod 667) ≡ 579 (mod 667)
369x (mod 941) ≡ 208 (mod 941)
590x (mod 769) ≡ 574 (mod 769)

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