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
685418126701-1
41826711511-12
2671511116-12-3
1511161352-35
11635311-35-18
3511325-1859
11251-1859-313
212059-313685
So our multiplicative inverse is -313 mod 685 ≡ 372
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
94912279501-7
122951271-78
9527314-78-31
27141138-3139
141311-3139-70
13113039-70949
So our multiplicative inverse is -70 mod 949 ≡ 879
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1978450197010
845197457101
1975732601-3
5726251-37
26551-37-38
51507-38197
So our multiplicative inverse is -38 mod 197 ≡ 159
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 ≡ 427 × 418-1 (mod 685) ≡ 427 × 372 (mod 685) ≡ 609 (mod 685)
x ≡ 957 × 122-1 (mod 949) ≡ 957 × 879 (mod 949) ≡ 389 (mod 949)
x ≡ 511 × 845-1 (mod 197) ≡ 511 × 159 (mod 197) ≡ 85 (mod 197)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 685 × 949 × 197 = 128062805
  2. We calculate the numbers M1 to M3
    M1=M/m1=128062805/685=186953,   M2=M/m2=128062805/949=134945,   M3=M/m3=128062805/197=650065
  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
    6851869530685010
    186953685272633101
    68563315201-1
    633521291-113
    52957-113-66
    971213-6679
    7231-6679-303
    212079-303685
    So our multiplicative inverse is -303 mod 685 ≡ 382
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9491349450949010
    134945949142187101
    94918751401-5
    187141351-566
    14524-566-137
    541166-137203
    4140-137203-949
    So our multiplicative inverse is 203 mod 949 ≡ 203
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1976500650197010
    6500651973299162101
    19716213501-1
    162354221-15
    3522113-15-6
    2213195-611
    13914-611-17
    942111-1745
    4140-1745-197
    So our multiplicative inverse is 45 mod 197 ≡ 45
    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
    =  (609 × 186953 × 382 +
       389 × 134945 × 203 +
       85 × 650065 × 45)   mod 128062805
    = 31312644 (mod 128062805)


    So our answer is 31312644 (mod 128062805).


Verification

So we found that x ≡ 31312644
If this is correct, then the following statements (i.e. the original equations) are true:
418x (mod 685) ≡ 427 (mod 685)
122x (mod 949) ≡ 957 (mod 949)
845x (mod 197) ≡ 511 (mod 197)

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