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
929571135801-1
57135812131-12
3582131145-12-3
2131451682-35
1456829-35-13
689755-1396
9514-1396-109
541196-109205
4140-109205-929
So our multiplicative inverse is 205 mod 929 ≡ 205
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
667475119201-1
4751922911-13
19291210-13-7
9110913-766
101100-766-667
So our multiplicative inverse is 66 mod 667 ≡ 66
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1076170107010
617107582101
1078212501-1
8225371-14
25734-14-13
74134-1317
4311-1317-30
313017-30107
So our multiplicative inverse is -30 mod 107 ≡ 77
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 ≡ 249 × 571-1 (mod 929) ≡ 249 × 205 (mod 929) ≡ 879 (mod 929)
x ≡ 88 × 475-1 (mod 667) ≡ 88 × 66 (mod 667) ≡ 472 (mod 667)
x ≡ 859 × 617-1 (mod 107) ≡ 859 × 77 (mod 107) ≡ 17 (mod 107)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 929 × 667 × 107 = 66301801
  2. We calculate the numbers M1 to M3
    M1=M/m1=66301801/929=71369,   M2=M/m2=66301801/667=99403,   M3=M/m3=66301801/107=619643
  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
    929713690929010
    7136992976765101
    929765116401-1
    76516441091-15
    164109155-15-6
    109551545-611
    555411-611-17
    54154011-17929
    So our multiplicative inverse is -17 mod 929 ≡ 912
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    667994030667010
    9940366714920101
    6672033701-33
    207261-3367
    7611-3367-100
    616067-100667
    So our multiplicative inverse is -100 mod 667 ≡ 567
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1076196430107010
    61964310757916101
    107617501-17
    65111-1718
    5150-1718-107
    So our multiplicative inverse is 18 mod 107 ≡ 18
    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
    =  (879 × 71369 × 912 +
       472 × 99403 × 567 +
       17 × 619643 × 18)   mod 66301801
    = 673475 (mod 66301801)


    So our answer is 673475 (mod 66301801).


Verification

So we found that x ≡ 673475
If this is correct, then the following statements (i.e. the original equations) are true:
571x (mod 929) ≡ 249 (mod 929)
475x (mod 667) ≡ 88 (mod 667)
617x (mod 107) ≡ 859 (mod 107)

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