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
52949013901-1
4903912221-113
3922117-113-14
22171513-1427
17532-1427-95
522127-95217
2120-95217-529
So our multiplicative inverse is 217 mod 529 ≡ 217
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
1914970191010
4971912115101
19111517601-1
115761391-12
7639137-12-3
3937122-35
372181-35-93
21205-93191
So our multiplicative inverse is -93 mod 191 ≡ 98
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
2713210271010
321271150101
2715052101-5
5021281-511
21825-511-27
851311-2738
5312-2738-65
321138-65103
2120-65103-271
So our multiplicative inverse is 103 mod 271 ≡ 103
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 ≡ 885 × 490-1 (mod 529) ≡ 885 × 217 (mod 529) ≡ 18 (mod 529)
x ≡ 167 × 497-1 (mod 191) ≡ 167 × 98 (mod 191) ≡ 131 (mod 191)
x ≡ 643 × 321-1 (mod 271) ≡ 643 × 103 (mod 271) ≡ 105 (mod 271)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 529 × 191 × 271 = 27381569
  2. We calculate the numbers M1 to M3
    M1=M/m1=27381569/529=51761,   M2=M/m2=27381569/191=143359,   M3=M/m3=27381569/271=101039
  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
    529517610529010
    5176152997448101
    52944818101-1
    448815431-16
    8143138-16-7
    4338156-713
    38573-713-98
    531213-98111
    3211-98111-209
    2120111-209529
    So our multiplicative inverse is -209 mod 529 ≡ 320
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    1911433590191010
    143359191750109101
    19110918201-1
    109821271-12
    822731-12-7
    2712702-7191
    So our multiplicative inverse is -7 mod 191 ≡ 184
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    2711010390271010
    101039271372227101
    27122714401-1
    22744571-16
    44762-16-37
    72316-37117
    2120-37117-271
    So our multiplicative inverse is 117 mod 271 ≡ 117
    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
    =  (18 × 51761 × 320 +
       131 × 143359 × 184 +
       105 × 101039 × 117)   mod 27381569
    = 11487253 (mod 27381569)


    So our answer is 11487253 (mod 27381569).


Verification

So we found that x ≡ 11487253
If this is correct, then the following statements (i.e. the original equations) are true:
490x (mod 529) ≡ 885 (mod 529)
497x (mod 191) ≡ 167 (mod 191)
321x (mod 271) ≡ 643 (mod 271)

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