Make the following equation correct by filling the blanks with the digits 0-9 (the 7 and 5 have been already placed for you):
7 _ _ _ _
─── = ───── + ─────
_ _ _ _ 5
... finds:
7 = 39 + 60
2 18 45
using:
DECLARE SUB permute (a$)
DEFDBL A-Z
CLS
a$ = "01234689": h$ = a$
n1 = 7
DO
d1 = VAL(MID$(a$, 1, 1))
n2 = VAL(MID$(a$, 2, 2))
d2 = VAL(MID$(a$, 4, 2))
n3 = VAL(MID$(a$, 6, 2))
d3 = VAL(MID$(a$, 8, 1) + "5")
dTot = d2 * d3 ' too lazy to put in LCM routine
nTot = n2 * d3 + n3 * d2
IF d1 * nTot = n1 * dTot THEN ' cross-multiply
PRINT n1, n2, n3
PRINT d1, d2, d3
END IF
permute a$
LOOP UNTIL a$ = h$
where the subroutine permute has been shown elsewhere on the site.
|
Posted by Charlie
on 2004-07-18 10:53:03 |