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
2894350289010
4352891146101
289146114301-1
146143131-12
1433472-12-95
32112-9597
2120-9597-289
So our multiplicative inverse is 97 mod 289 ≡ 97
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
908115710301-7
1151031121-78
1031287-78-71
127158-7179
7512-7179-150
522179-150379
2120-150379-908
So our multiplicative inverse is 379 mod 908 ≡ 379
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
961346226901-2
3462691771-23
26977338-23-11
7738213-1125
381380-1125-961
So our multiplicative inverse is 25 mod 961 ≡ 25
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 ≡ 354 × 435-1 (mod 289) ≡ 354 × 97 (mod 289) ≡ 236 (mod 289)
x ≡ 370 × 115-1 (mod 908) ≡ 370 × 379 (mod 908) ≡ 398 (mod 908)
x ≡ 14 × 346-1 (mod 961) ≡ 14 × 25 (mod 961) ≡ 350 (mod 961)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 289 × 908 × 961 = 252177932
  2. We calculate the numbers M1 to M3
    M1=M/m1=252177932/289=872588,   M2=M/m2=252177932/908=277729,   M3=M/m3=252177932/961=262412
  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
    2898725880289010
    872588289301997101
    2899729501-2
    9795121-23
    952471-23-143
    21203-143289
    So our multiplicative inverse is -143 mod 289 ≡ 146
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9082777290908010
    277729908305789101
    908789111901-1
    7891196751-17
    11975144-17-8
    75441317-815
    4431113-815-23
    31132515-2361
    13523-2361-145
    531261-145206
    3211-145206-351
    2120206-351908
    So our multiplicative inverse is -351 mod 908 ≡ 557
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9612624120961010
    26241296127359101
    96159161701-16
    5917381-1649
    17821-1649-114
    818049-114961
    So our multiplicative inverse is -114 mod 961 ≡ 847
    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
    =  (236 × 872588 × 146 +
       398 × 277729 × 557 +
       350 × 262412 × 847)   mod 252177932
    = 215168250 (mod 252177932)


    So our answer is 215168250 (mod 252177932).


Verification

So we found that x ≡ 215168250
If this is correct, then the following statements (i.e. the original equations) are true:
435x (mod 289) ≡ 354 (mod 289)
115x (mod 908) ≡ 370 (mod 908)
346x (mod 961) ≡ 14 (mod 961)

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