You go to the bank and take out some money (say X dollars and Y cents). By mistake, the teller gives you dollars instead of cents and cents instead of dollars, i.e. you got Y dollars and X cents. On the way home, you buy a newspaper for 20 cents. When you get home, you find you have twice as much money in your wallet as what you had originally intended to withdraw. What are X and Y?
The equation for X and Y is:
100 Y + X – 20 = 2 (100 X + Y) which can be simplified to
98Y = 199X+20
We have only one equation for two unknowns. However, X and Y are constrained in value. They are both nonzero, positive integers and less than 100: 0 < X < 100, 0 < Y < 100. The trick to find the solution is to express X and Y in terms of some other integer valued parameter. The steps are as follows:
Y = 2X + (3X+20)/98. But since X and Y are integers, so must (3X+20)/98 be.
Let t = (3X+20)/98, t = integer.
Then X = 33t – (t+20)/3
Thus, (t+20)/3 must also be an integer.
Let w = (t+20)/3. Then, t = 3w-20 and hence,
X = 33t – w = 98w - 660 and
Y = t + 2X = 199w - 1340
Substituting w = 1,2,3,.. we see that the only possible solution which satisfies 0 < X < 100 and 0 < Y < 100 is obtained for w = 7. This gives, X = 26, Y = 53. We can check that there are no other solutions by noting that for w = 6 or less, the solutions are negative and for w = 8 or greater they are greater than 100. Hence the unique solution is that you asked for $26.53 from the bank. Instead, the teller gave you $53.26. After buying the newspaper, you had $53.06 left, and this is twice what you had asked the teller for because $53.06 = 2 x ($26.53) !