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
1193270119010
327119289101
1198913001-1
89302291-13
302911-13-4
2912903-4119
So our multiplicative inverse is -4 mod 119 ≡ 115
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
4199800419010
9804192142101
419142213501-2
142135171-23
1357192-23-59
72313-59180
2120-59180-419
So our multiplicative inverse is 180 mod 419 ≡ 180
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
3075480307010
5483071241101
30724116601-1
241663431-14
6643123-14-5
43231204-59
232013-59-14
203629-1493
3211-1493-107
212093-107307
So our multiplicative inverse is -107 mod 307 ≡ 200
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 ≡ 150 × 327-1 (mod 119) ≡ 150 × 115 (mod 119) ≡ 114 (mod 119)
x ≡ 481 × 980-1 (mod 419) ≡ 481 × 180 (mod 419) ≡ 266 (mod 419)
x ≡ 809 × 548-1 (mod 307) ≡ 809 × 200 (mod 307) ≡ 11 (mod 307)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 119 × 419 × 307 = 15307327
  2. We calculate the numbers M1 to M3
    M1=M/m1=15307327/119=128633,   M2=M/m2=15307327/419=36533,   M3=M/m3=15307327/307=49861
  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
    1191286330119010
    1286331191080113101
    1191131601-1
    11361851-119
    6511-119-20
    515019-20119
    So our multiplicative inverse is -20 mod 119 ≡ 99
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    419365330419010
    365334198780101
    4198051901-5
    8019441-521
    19443-521-89
    431121-89110
    3130-89110-419
    So our multiplicative inverse is 110 mod 419 ≡ 110
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    307498610307010
    49861307162127101
    30712725301-2
    127532211-25
    5321211-25-12
    21111105-1217
    111011-1217-29
    10110017-29307
    So our multiplicative inverse is -29 mod 307 ≡ 278
    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
    =  (114 × 128633 × 99 +
       266 × 36533 × 110 +
       11 × 49861 × 278)   mod 15307327
    = 9707658 (mod 15307327)


    So our answer is 9707658 (mod 15307327).


Verification

So we found that x ≡ 9707658
If this is correct, then the following statements (i.e. the original equations) are true:
327x (mod 119) ≡ 150 (mod 119)
980x (mod 419) ≡ 481 (mod 419)
548x (mod 307) ≡ 809 (mod 307)

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