This is a generalization of
Rupees and Paise.
Stan entered a departmental store with A dollars and B cents. When he exited the store, he had B/p dollars and A cents, where B/p is
an integer. It was observed that when Stan came out, he had precisely 1/p times the money he had when he came in.
Given that each of A, B and p is a
positive integer, with 2 ≤ p ≤ 99, determine the values of p for which this is possible. What values of p generate more than one solution?
DEFDBL A-Z
CLS
FOR p = 2 TO 99
FOR a = 1 TO 99
FOR b = p TO 99 STEP p
IF ((b / p) * 100 + a) * p = a * 100 + b THEN
PRINT p, a; b, b / p; a
END IF
NEXT b
NEXT a
NEXT p
finds all the solutions:
entered left
with with
p a b b/p a
2 99 98 49 99
4 33 32 8 33
4 66 64 16 66
4 99 96 24 99
5 99 95 19 99
10 11 10 1 11
10 22 20 2 22
10 33 30 3 33
10 44 40 4 44
10 55 50 5 55
10 66 60 6 66
10 77 70 7 77
10 88 80 8 88
10 99 90 9 99
12 27 24 2 27
12 54 48 4 54
12 81 72 6 81
20 99 80 4 99
25 33 25 1 33
25 66 50 2 66
25 99 75 3 99
28 77 56 2 77
34 51 34 1 51
40 66 40 1 66
45 81 45 1 81
50 99 50 1 99
(blank lines inserted manually between p values)
So p can be 2, 4, 5, 10, 12, 20, 25, 28, 34, 40, 45 or 50
among which
p = 4, 10, 12 and 25 lead to multiple solutions.
|
Posted by Charlie
on 2012-08-13 12:43:47 |