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
3899870389010
9873892209101
389209118001-1
2091801291-12
1802966-12-13
296452-1354
6511-1354-67
515054-67389
So our multiplicative inverse is -67 mod 389 ≡ 322
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
971602136901-1
60236912331-12
3692331136-12-3
2331361972-35
13697139-35-8
97392195-821
391921-821-50
19119021-50971
So our multiplicative inverse is -50 mod 971 ≡ 921
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
28324111901-11
2419151-1112
19534-1112-47
541112-4759
4140-4759-283
So our multiplicative inverse is 59 mod 283 ≡ 59
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 ≡ 476 × 987-1 (mod 389) ≡ 476 × 322 (mod 389) ≡ 6 (mod 389)
x ≡ 395 × 602-1 (mod 971) ≡ 395 × 921 (mod 971) ≡ 641 (mod 971)
x ≡ 346 × 24-1 (mod 283) ≡ 346 × 59 (mod 283) ≡ 38 (mod 283)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 389 × 971 × 283 = 106894477
  2. We calculate the numbers M1 to M3
    M1=M/m1=106894477/389=274793,   M2=M/m2=106894477/971=110087,   M3=M/m3=106894477/283=377719
  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
    3892747930389010
    274793389706159101
    38915927101-2
    159712171-25
    711743-25-22
    173525-22115
    3211-22115-137
    2120115-137389
    So our multiplicative inverse is -137 mod 389 ≡ 252
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9711100870971010
    110087971113364101
    971364224301-2
    36424311211-23
    24312121-23-8
    121112103-8971
    So our multiplicative inverse is -8 mod 971 ≡ 963
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2833777190283010
    3777192831334197101
    28319718601-1
    197862251-13
    8625311-13-10
    2511233-1023
    11332-1023-79
    321123-79102
    2120-79102-283
    So our multiplicative inverse is 102 mod 283 ≡ 102
    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
    =  (6 × 274793 × 252 +
       641 × 110087 × 963 +
       38 × 377719 × 102)   mod 106894477
    = 32266000 (mod 106894477)


    So our answer is 32266000 (mod 106894477).


Verification

So we found that x ≡ 32266000
If this is correct, then the following statements (i.e. the original equations) are true:
987x (mod 389) ≡ 476 (mod 389)
602x (mod 971) ≡ 395 (mod 971)
24x (mod 283) ≡ 346 (mod 283)

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