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
857663119401-1
6631943811-14
19481232-14-9
81322174-922
3217115-922-31
17151222-3153
15271-3153-402
212053-402857
So our multiplicative inverse is -402 mod 857 ≡ 455
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
89881118701-1
811879281-110
872833-110-31
2839110-31289
3130-31289-898
So our multiplicative inverse is 289 mod 898 ≡ 289
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4017260401010
7264011325101
40132517601-1
325764211-15
7621313-15-16
2113185-1621
13815-1621-37
851321-3758
5312-3758-95
321158-95153
2120-95153-401
So our multiplicative inverse is 153 mod 401 ≡ 153
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 ≡ 346 × 663-1 (mod 857) ≡ 346 × 455 (mod 857) ≡ 599 (mod 857)
x ≡ 180 × 811-1 (mod 898) ≡ 180 × 289 (mod 898) ≡ 834 (mod 898)
x ≡ 72 × 726-1 (mod 401) ≡ 72 × 153 (mod 401) ≡ 189 (mod 401)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 857 × 898 × 401 = 308603986
  2. We calculate the numbers M1 to M3
    M1=M/m1=308603986/857=360098,   M2=M/m2=308603986/898=343657,   M3=M/m3=308603986/401=769586
  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
    8573600980857010
    360098857420158101
    85715856701-5
    158672241-511
    6724219-511-27
    24191511-2738
    19534-2738-141
    541138-141179
    4140-141179-857
    So our multiplicative inverse is 179 mod 857 ≡ 179
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    8983436570898010
    343657898382621101
    898621127701-1
    6212772671-13
    2776749-13-13
    679743-1394
    9421-1394-201
    414094-201898
    So our multiplicative inverse is -201 mod 898 ≡ 697
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    4017695860401010
    769586401191967101
    4016756601-5
    6766111-56
    661660-56-401
    So our multiplicative inverse is 6 mod 401 ≡ 6
    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
    =  (599 × 360098 × 179 +
       834 × 343657 × 697 +
       189 × 769586 × 6)   mod 308603986
    = 81815818 (mod 308603986)


    So our answer is 81815818 (mod 308603986).


Verification

So we found that x ≡ 81815818
If this is correct, then the following statements (i.e. the original equations) are true:
663x (mod 857) ≡ 346 (mod 857)
811x (mod 898) ≡ 180 (mod 898)
726x (mod 401) ≡ 72 (mod 401)

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