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
4616370461010
6374611176101
461176210901-2
1761091671-23
10967142-23-5
67421253-58
4225117-58-13
2517188-1321
17821-1321-55
818021-55461
So our multiplicative inverse is -55 mod 461 ≡ 406
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
55718131401-3
1811412131-337
141311-337-40
13113037-40557
So our multiplicative inverse is -40 mod 557 ≡ 517
Source: ExtendedEuclideanAlgorithm.com

nbqr t1t2t3
997813118401-1
8131844771-15
18477230-15-11
77302175-1127
3017113-1127-38
17131427-3865
13431-3865-233
414065-233997
So our multiplicative inverse is -233 mod 997 ≡ 764
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 ≡ 655 × 637-1 (mod 461) ≡ 655 × 406 (mod 461) ≡ 394 (mod 461)
x ≡ 807 × 181-1 (mod 557) ≡ 807 × 517 (mod 557) ≡ 26 (mod 557)
x ≡ 798 × 813-1 (mod 997) ≡ 798 × 764 (mod 997) ≡ 505 (mod 997)


Now the actual calculation

  1. Find the common modulus M
    M = m1 × m2 × ... × mk = 461 × 557 × 997 = 256006669
  2. We calculate the numbers M1 to M3
    M1=M/m1=256006669/461=555329,   M2=M/m2=256006669/557=459617,   M3=M/m3=256006669/997=256777
  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
    4615553290461010
    5553294611204285101
    461285117601-1
    28517611091-12
    176109167-12-3
    109671422-35
    6742125-35-8
    42251175-813
    251718-813-21
    1782113-2155
    8180-2155-461
    So our multiplicative inverse is 55 mod 461 ≡ 55
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    5574596170557010
    45961755782592101
    557926501-6
    9251821-6109
    5221-6109-224
    2120109-224557
    So our multiplicative inverse is -224 mod 557 ≡ 333
    Source: ExtendedEuclideanAlgorithm.com

    nbqr t1t2t3
    9972567770997010
    256777997257548101
    997548144901-1
    5484491991-12
    44999453-12-9
    99531462-911
    534617-911-20
    4676411-20131
    7413-20131-151
    4311131-151282
    3130-151282-997
    So our multiplicative inverse is 282 mod 997 ≡ 282
    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
    =  (394 × 555329 × 55 +
       26 × 459617 × 333 +
       505 × 256777 × 282)   mod 256006669
    = 99588841 (mod 256006669)


    So our answer is 99588841 (mod 256006669).


Verification

So we found that x ≡ 99588841
If this is correct, then the following statements (i.e. the original equations) are true:
637x (mod 461) ≡ 655 (mod 461)
181x (mod 557) ≡ 807 (mod 557)
813x (mod 997) ≡ 798 (mod 997)

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