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?
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.
Log in to reply
That looks so short! How come?
Log in to reply
Python rocks, the program is a kind of just one line program !
How about back substitution? It worked for me.
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 )
( 2 ) x ≡ 0 ( m o d 1 1 )
( 3 ) x ≡ 1 ( m o d 1 3 )
( 4 ) x ≡ 3 ( m o d 1 9 )
Now, using the variable conventions in the page, we obtain N , n i , and y i :
N = 9 × 1 1 × 1 3 × 1 9 = 2 4 4 5 3
n 1 = 9 , y 1 = n 1 N = 2 7 1 7
n 2 = 1 1 , y 2 = n 2 N = 2 2 2 3
n 3 = 1 3 , y 3 = n 3 N = 1 8 8 1
n 4 = 1 9 , y 4 = n 4 N = 1 2 8 7
Next, we find z i ≡ y i − 1 ( m o d n i ) :
z 1 ≡ 2 7 1 7 − 1 ≡ ( − 1 ) − 1 ≡ − 1 ≡ 8 ( m o d 9 )
z 2 ≡ 2 2 2 3 − 1 ≡ 1 − 1 ≡ 1 ( m o d 1 1 )
z 3 ≡ 1 8 8 1 − 1 ≡ 9 − 1 ≡ 3 ( m o d 1 3 )
z 4 ≡ 1 2 8 7 − 1 ≡ 1 4 − 1 ≡ − 4 ≡ 1 5 ( m o d 1 9 )
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 ≡ ( 4 ) ( 2 7 1 7 ) ( 8 ) + ( 0 ) ( 2 2 2 3 ) ( 1 ) + ( 1 ) ( 1 8 8 1 ) ( 3 ) + ( 3 ) ( 1 2 8 7 ) ( 1 5 ) ( m o d 2 4 4 5 3 )
x ≡ 3 7 8 4 ( m o d 2 4 4 5 3 )
Finally, the second solution of this is 2 4 4 5 3 + 3 7 8 4 = 2 8 2 3 7
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.
Log in to reply
That was too tough a calculation by hand...
Log in to reply
Did you write a program?
Can u please give a more simplified solution...
I'm not satisfy with any ans...
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!
Log in to reply
Yes, type in the cell (w/o quotes) "=MOD(<dividend>,<divisor>)"
Problem Loading...
Note Loading...
Set Loading...
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 ) , x ≡ 3 ( m o d 1 9 )
( 2 ) x ≡ 0 ( m o d 1 1 ) , x ≡ 1 ( m o d 1 3 )
Solving the 1st 2, you get x ≡ 2 2 ( m o d 1 7 1 )
This is because by Bezout's theorem
1 × 1 9 − 2 × 9 = 1
hence the common solution will be
4 × 1 9 × 1 + ( − 2 ) × 9 × 3 ( m o d 1 7 1 ) = 7 6 − 5 4 = 2 2 ( m o d 1 7 1 )
And solving the second pair, because by Bezout's theorem, you get
6 × 1 1 − 5 × 1 3 = 1 , so the common solution will be 6 × 1 1 ( m o d 1 4 3 ) = 6 6 ( m o d 1 4 3 )
Hence the task is finding common solution of
x ≡ 2 2 ( m o d 1 7 1 )
x ≡ 6 6 ( m o d 1 4 3 )
( I will work this one completely to show how bezout's theorem is used)
1 7 1 = 1 4 3 + 2 8
1 4 3 = 2 8 × 5 + 3
Hence we get
1 = 2 8 − 9 × 3
1 = 1 7 1 − 1 4 3 − 9 ( 1 4 3 − 2 8 × 5 )
1 = 1 7 1 − 1 4 3 − 9 ( 1 4 3 − 5 ( 1 7 1 − 1 4 3 ) )
1 = 1 7 1 − 1 4 3 + 4 5 × 1 7 1 − 5 4 × 1 4 3 = 4 6 × 1 7 1 − 5 5 × 1 4 3
Thus in the linear congruences system, your answer will be ( m o d 1 4 3 × 1 7 1 ) and it will be
2 2 × 1 4 3 × ( − 5 5 ) + 6 6 × 1 7 1 × 4 6 ≡ 3 4 6 1 2 6 ≡ 3 7 8 4 ( m o d 2 4 4 5 3 )
This means that the solution of out original system is
x ≡ 3 7 8 4 ( m o d 2 4 4 5 3 )
And the second solution of this is 3 7 8 4 + 2 4 4 5 3 = 2 8 2 3 7