# Absent minded clerk

1. Sep 18, 2006

### castaway

An absent minded clerk switched the dollars and cents when he cashed a cheque for Mr Brown , giving him dollars instead of cents, and cents instead of dollars.
After buying a five cent newspaper,Brown discovered that he left excatly twice as much as his original cheque.

What was the amount of the cheque?

P.S : i read this in a book where the solution was not given!

2. Sep 19, 2006

### Jimmy Snyder

The original check was for $31.63, which doubled is$63.26.
The clerk gave Mr. Brown $63.31. After Mr. Brown spent$.05, he was left with $63.26 which is double the original check. I solved this by a little analysis and a lot of brute force: The analysis: 100a + b - 5 = 2 (100b + a) or 98a - 199b = 5 The brute force: #include <stdio.h> main () { long a, b; for (a = 0; a < 100; ++a) { for (b = 0; b < 100; ++b) { long c = 98 * a - 199 * b; if (5 == c) { printf ("%d.%02d\n", a, b); } } } } EOM 3. Sep 19, 2006 ### Piet Pols At first sight this problem looks insolvable as you end up with one equasion and two unknowns. However, you do not need brute force, since you have more information i.e. the number of dollars and the number of cents need to be natural numbers and the number of cents can never exceed 99. Is this enough clue? Last edited: Sep 19, 2006 4. Sep 19, 2006 ### Jimmy Snyder I knew that this was a type of problem called a diophantine equation. However, I assumed that I would be able to write and run the program much quicker than it would take to learn how to handle such equations. But after you posted your message, I felt challenged to study up on it. I used the MathWorld page as a guide. Here is a more elegant solution (with the meaning of a and b swapped from my original post). -199a + 98b = 5 199 = 2 * 98 + 3 98 = 32 * 3 + 2 3 = 1 * 2 + 1 1 = 1 * 3 - 1* 2 1 = -1 * 98 + 33 * 3 1 = 33 * 199 - 67 * 98 5 = 165 * 199 - 335 * 98 5 = (-165) * (-199) - 335 * 98 5 = (-165 + 2 * 98) * (-199) - (335 - 2 * 199) * 98 5 = 31 * (-199) + 63 * 98 so a = 31, b = 63, and the original check is for$31.63

EOM

5. Sep 19, 2006

### castaway

well yes , i guess i was missing this clue that cents cant exceed 100 , i was taking 2 variables x and y and then i was getting a diophoantine equation , well which has infinite solution , thank you , i was really curious, i got the answer now