When 16 is subtracted from a three-digit number, and the resulting difference is divided by 2, the result is a three-digit number whose digits are those of the original number, but in reverse order. The sum of the three digits is 20. Find the original number.
a=0;b=0;c=0;p=0; cycle:d=a*100+b*10+c;if((d - 16) / 2 ==c*100+b*10 + a and (a+b+c) == 20, goto loop, goto next); loop:printd," ",;p=p+1; next:c++;if(c<10, goto cycle, 0);c=0;b++;if(b<10, goto cycle, 0);b=0;c=0;a++;if(a<10, goto cycle,0);print"Total = ",p
OUTPUT = 974
When 16 is subtracted from a three-digit number, and the resulting difference is divided by 2, the result is a three-digit number whose digits are those of the original number, but in reverse order. The sum of the three digits is 20. Find the original number.
\(\frac{100x+10y+z-16}{2}=100z+10y+x \qquad and \qquad x+y+z=20\\~\\ \)
Where x,y and z are single digit non-negative integers. And x and z cannot be 0
Looking at
\(\frac{100x+10y+z-16}{2}=50x+5y+\frac{z}{2}-8\)
Z must be 2,4,6 or 8
Z, 10+Z | 2,12 | 4,14 | 6,16 | 8,18 |
z/2, (10+Z)/2 | 1,6 | 2,7 | 3,8 | 4,9 |
z/2-8 (last digit) | 3,8 | 4,9 | 5,0 | 6,1 |
X | 3 or 8 | 4 or 9 | 5 or 0 | 6 or 1 |
x+y+z=20 therefor Y= | no soln | 7 (using the 9) | 9 (using the 5) | 6(using the 6) |
possible initial numbers | 974 | 596 | 668 |
So my possibilities so far are
974 and 596 abd 668
do they work though?
the digits add to 20, that is good.
Try 974
(974-16)/2 = 479 The digits are reversed so that is perfect
Try 596
(596-16)/2 = 290 that is no good
Try 668
(668-16)/2 = 326 that is no good either.
So the only original number that works is 974
Coding:
\frac{100x+10y+z-16}{2}=100z+10y+x \qquad and \qquad x+y+z=20\\~\\
Let the original number be abc....so we can write
a + b + c = 20
c = 20 - a - b
[100a + 10b + c -16 ] / 2 = 100c + 10b + a
100a + 10b + c - 16 = 200c + 20b + 2a
100a + 10b + ( 20 - a - b) - 16 = 200 (20 - a - b) + 20b + 2a
99a + 9b + 4 = 4000 - 200a - 200b + 20b + 2a
99a + 9b + 4 = 4000 - 198a - 180b
297a + 189b = 3996 divide both sides by 9
33a + 21b = 444 divide by 3 again
11a + 7b = 148
11a = 148 - 7b
Note that if a = 9 , then b = 7
And c = 20 - 9 - 7 = 4
So.....the original number is 974
Proof
[974 - 16]/ 2 =
958/2 =
479