Counting Soldiers Discreetly

According to Chinese folklore, to avoid spies overhearing the size of his army, general Han Xin gave his messenger only the remainder of soldiers in rectangular formations.

He said, "When my soldiers assemble in rows of 9, four remain; in rows of 11, none remain; in rows of 13, only one remain; in rows of 19, three remain."

Han Xin also told his messenger that the number is the second smallest solution. How many soldiers is he commanding?


The answer is 28237.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Aditya Raut
Jul 25, 2014

We apply the Chinese remainder theorem here. We have 4 linear congruences, make them as pairs of 2,

( 1 ) x 4 ( m o d 9 ) \color{#D61F06}{(1)} \quad \quad x\equiv 4 \pmod{9} , x 3 ( m o d 19 ) \quad \quad x\equiv 3 \pmod{19}

( 2 ) x 0 ( m o d 11 ) \color{#D61F06}{(2)}\quad \quad x\equiv 0 \pmod{11} , x 1 ( m o d 13 ) \quad \quad x\equiv 1 \pmod{13}

Solving the 1st 2, you get x 22 ( m o d 171 ) x\equiv 22 \pmod{171}

This is because by Bezout's theorem

1 × 19 2 × 9 = 1 1\times 19 - 2\times 9 = 1

hence the common solution will be

4 × 19 × 1 + ( 2 ) × 9 × 3 ( m o d 171 ) = 76 54 = 22 ( m o d 171 ) 4\times 19\times 1+ (-2)\times 9 \times 3 \pmod{171} = 76-54 = 22 \pmod{171}

And solving the second pair, because by Bezout's theorem, you get

6 × 11 5 × 13 = 1 6\times 11 - 5\times 13 =1 , so the common solution will be 6 × 11 ( m o d 143 ) = 66 ( m o d 143 ) 6\times 11 \pmod{143} = 66\pmod{143}

Hence the task is finding common solution of

x 22 ( m o d 171 ) \quad \quad x\equiv 22 \pmod{171}

x 66 ( m o d 143 ) \quad \quad x\equiv 66 \pmod{ 143}

( I will work this one completely to show how bezout's theorem is used)

171 = 143 + 28 171=143 +28

143 = 28 × 5 + 3 143=28\times 5 +3

Hence we get

1 = 28 9 × 3 1=28 -9\times 3

1 = 171 143 9 ( 143 28 × 5 ) 1=171-143 - 9 (143-28\times 5)

1 = 171 143 9 ( 143 5 ( 171 143 ) ) 1= 171-143 - 9(143-5(171-143))

1 = 171 143 + 45 × 171 54 × 143 = 46 × 171 55 × 143 1=171-143+45\times 171 - 54\times 143 = 46\times 171 - 55\times 143

Thus in the linear congruences system, your answer will be ( m o d 143 × 171 ) \pmod{143\times 171} and it will be

22 × 143 × ( 55 ) + 66 × 171 × 46 346126 3784 ( m o d 24453 ) 22\times 143\times (-55) + 66\times 171\times 46 \equiv 346126 \equiv 3784 \pmod{24453}

This means that the solution of out original system is \color{#D61F06}{\textbf{This means that the solution of out original system is }}

x 3784 ( m o d 24453 ) \displaystyle x\equiv 3784 \pmod{24453}

And the second solution of this is 3784 + 24453 = 28237 3784+24453 = \boxed{28237}

Ok, I just found an awesome bash using the python programming.

LOL LOL

Aditya Raut - 6 years, 10 months ago

Log in to reply

That looks so short! How come?

Steven Zheng - 6 years, 10 months ago

Log in to reply

Python rocks, the program is a kind of just one line program !

Aditya Raut - 6 years, 10 months ago

How about back substitution? It worked for me.

Aneesh Kundu - 6 years, 10 months ago

Log in to reply

What do you mean...Please elaborate.

Jayakumar Krishnan - 6 years, 10 months ago
Benjamin Beach
Jan 4, 2015

This can be done via a direct application of the Chinese Remainder Theorem to the system of equations:

( 1 ) x 4 ( m o d 9 ) \color{#D61F06}{(1)} \quad \quad x\equiv4 \pmod{9}

( 2 ) x 0 ( m o d 11 ) \color{#D61F06}{(2)} \quad \quad x\equiv0 \pmod{11}

( 3 ) x 1 ( m o d 13 ) \color{#D61F06}{(3)} \quad \quad x\equiv1 \pmod{13}

( 4 ) x 3 ( m o d 19 ) \color{#D61F06}{(4)} \quad \quad x\equiv3 \pmod{19}

Now, using the variable conventions in the page, we obtain N N , n i n_i , and y i y_i :

N = 9 × 11 × 13 × 19 = 24453 N = 9 \times 11 \times 13 \times 19 = \mathbf{24453}

n 1 = 9 , y 1 = N n 1 = 2717 n_1 = 9, \quad \quad y_1 = {N \over{n_1}} = \mathbf{2717}

n 2 = 11 , y 2 = N n 2 = 2223 n_2 = 11, \quad \quad y_2 = {N \over{n_2}} = \mathbf{2223}

n 3 = 13 , y 3 = N n 3 = 1881 n_3 = 13, \quad \quad y_3 = {N \over{n_3}} = \mathbf{1881}

n 4 = 19 , y 4 = N n 4 = 1287 n_4 = 19, \quad \quad y_4 = {N \over{n_4}} = \mathbf{1287}

Next, we find z i y i 1 ( m o d n i ) z_i \equiv y_i^{-1} \pmod{n_i} :

z 1 271 7 1 ( 1 ) 1 1 8 ( m o d 9 ) z_1 \equiv 2717^{-1} \equiv (-1)^{-1} \equiv -1 \equiv \mathbf{8} \pmod{9}

z 2 222 3 1 1 1 1 ( m o d 11 ) z_2 \equiv 2223^{-1} \equiv 1^{-1} \equiv \mathbf{1} \pmod{11}

z 3 188 1 1 9 1 3 ( m o d 13 ) z_3 \equiv 1881^{-1} \equiv 9^{-1} \equiv \mathbf{3} \pmod{13}

z 4 128 7 1 1 4 1 4 15 ( m o d 19 ) z_4 \equiv 1287^{-1} \equiv 14^{-1} \equiv -4 \equiv \mathbf{15} \pmod{19}

These inverses were found via the extended Euclidean algorithm.

Next, to obtain the smallest solution, we apply x i = 1 4 a i y i z i ( m o d N ) x \equiv \sum_{i=1}^4{a_iy_iz_i} \pmod N :

x ( 4 ) ( 2717 ) ( 8 ) + ( 0 ) ( 2223 ) ( 1 ) + ( 1 ) ( 1881 ) ( 3 ) + ( 3 ) ( 1287 ) ( 15 ) ( m o d 24453 ) x \equiv (4)(2717)(8) + (0)(2223)(1) + (1)(1881)(3) + (3)(1287)(15) \pmod{24453}

x 3784 ( m o d 24453 ) x \equiv \mathbf{3784} \pmod{24453}

Finally, the second solution of this is 24453 + 3784 = 28237 24453 + 3784 = \boxed{\mathbf{28237}}

Naimish Khara
Jul 21, 2014

I have solved it in following manner. first the number which satisfies two condition(11-13) is 66. after that i added (11 13=)143 in it until it satisfy third condition (9) that number is 1210 and than i added (143 9)=1287 until it satisfy fourth condition(19) so I find that number 3784 satisfies all this condition to find solution I added(9 13 11*19)=24,453 and I got ans. which is 28,237

Interesting. This problem exploits the Chinese Remainder Theorem and its subsequent algorithm. Your explanation looks very simplified, but it did solve the problem.

Steven Zheng - 6 years, 10 months ago

Log in to reply

That was too tough a calculation by hand...

Peter Finn - 6 years, 10 months ago

Log in to reply

Did you write a program?

Steven Zheng - 6 years, 10 months ago

Log in to reply

@Steven Zheng No, I wasted pages, instead!

Peter Finn - 6 years, 10 months ago

Can u please give a more simplified solution...

Lakshaya Bangur - 6 years, 10 months ago

I'm not satisfy with any ans...

AMISHA WASNIK - 6 years, 10 months ago
Miko Mido
Jul 24, 2014

I'm not sure if my solution would be valid because I have a need to use an application to be able to solve this. I used MS Excel to solve this problem. Since there is no remainder for multiples of 11, I'm using this as basis. So column 1 consists of multiples of 11, that is Row 1 = 11, Row 2 = 22, and so on.

Column 2 is "=MOD(Ax,9) Column 3 is "=MOD(Ax,13) Column 4 is "=MOD(Ax,19)

Where x is row number. We're finding the following values: Ax (any multiple of 11), 4, 1, 3 in a single row. I used Conditional formatting using colors and find an all colored row. Drag down the formula. You can simply check each rows but to make it easier I added 1 more row with formula "=Bx-Cx-Dx" then I filtered those with answer as "0" which will show up lots of answers but you can easily see a colored row. The 1st value is 3784 but we are looking for the 2nd smallest and that will be seen at row 2567 with a value of 28237.

Note: Actually filtering B, C and D column to find values of 4, 1, 3 is easier that what I did.

I hope this helps even though it is not a pen and paper type of solution.

Cheers.

Wait, MS Excel can do mod? I hardly use it so I never knew!

Steven Zheng - 6 years, 10 months ago

Log in to reply

Yes, type in the cell (w/o quotes) "=MOD(<dividend>,<divisor>)"

Miko Mido - 6 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...