Find a number ABCDEFGHIJ, with all its digits different, such that:
- A, C, E, G, and I are odd
- HIJ is a multiple of BCD
- GH is a multiple of AB
- HIJ/BCD equals GH/AB
DECLARE SUB permute (a$)
CLS
DEFDBL A-Z
odd$ = "13579": even$ = "02468"
oddH$ = odd$
DO
evenH$ = even$
DO
hij$ = MID$(even$, 4, 1) + RIGHT$(odd$, 1) + RIGHT$(even$, 1)
bcd$ = LEFT$(even$, 1) + MID$(odd$, 2, 1) + MID$(even$, 2, 1)
gh$ = MID$(odd$, 4, 1) + MID$(even$, 4, 1)
ab$ = LEFT$(odd$, 1) + LEFT$(even$, 1)
IF VAL(gh$) / VAL(ab$) = VAL(hij$) / VAL(bcd$) THEN
FOR i = 1 TO 5
PRINT MID$(odd$, i, 1) + MID$(even$, i, 1);
NEXT
PRINT VAL(gh$) / VAL(ab$)
END IF
permute even$
LOOP UNTIL even$ = evenH$
permute odd$
LOOP UNTIL odd$ = oddH$
finds all the cases where the given ratios are equal:
3218709654 3
3476905812 1.705882352941176
5812903476 .5862068965517241
9654703218 .3333333333333333
but the ratio of only the first is an integer, so that is the answer.
|
Posted by Charlie
on 2006-07-31 14:11:55 |