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
79593079010
59379740101
794013901-1
4039111-12
391390-12-79
So our multiplicative inverse is 2 mod 79 ≡ 2
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
8939760893010
976893183101
89383106301-10
83631201-1011
632033-1011-43
2036211-43269
3211-43269-312
2120269-312893
So our multiplicative inverse is -312 mod 893 ≡ 581
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1975590197010
5591972165101
19716513201-1
16532551-16
32562-16-37
52216-3780
2120-3780-197
So our multiplicative inverse is 80 mod 197 ≡ 80
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 ≡ 976 × 593-1 (mod 79) ≡ 976 × 2 (mod 79) ≡ 56 (mod 79)
x ≡ 445 × 976-1 (mod 893) ≡ 445 × 581 (mod 893) ≡ 468 (mod 893)
x ≡ 188 × 559-1 (mod 197) ≡ 188 × 80 (mod 197) ≡ 68 (mod 197)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 79 × 893 × 197 = 13897759
  2. We calculate the numbers M1 to M3
    M1=M/m1=13897759/79=175921,   M2=M/m2=13897759/893=15563,   M3=M/m3=13897759/197=70547
  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
    79175921079010
    17592179222667101
    796711201-1
    6712571-16
    12715-16-7
    75126-713
    5221-713-33
    212013-3379
    So our multiplicative inverse is -33 mod 79 ≡ 46
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    893155630893010
    1556389317382101
    893382212901-2
    38212921241-25
    12912415-25-7
    12452445-7173
    5411-7173-180
    4140173-180893
    So our multiplicative inverse is -180 mod 893 ≡ 713
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    197705470197010
    7054719735821101
    197219801-9
    218251-919
    8513-919-28
    531219-2847
    3211-2847-75
    212047-75197
    So our multiplicative inverse is -75 mod 197 ≡ 122
    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
    =  (56 × 175921 × 46 +
       468 × 15563 × 713 +
       68 × 70547 × 122)   mod 13897759
    = 5358468 (mod 13897759)


    So our answer is 5358468 (mod 13897759).


Verification

So we found that x ≡ 5358468
If this is correct, then the following statements (i.e. the original equations) are true:
593x (mod 79) ≡ 976 (mod 79)
976x (mod 893) ≡ 445 (mod 893)
559x (mod 197) ≡ 188 (mod 197)

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