DEFDBL A-Z
minn = 99999999: minm = minn
FOR a = 1 TO 9
FOR b = 0 TO 9
apb = INT(a ^ b + .5)
FOR c = 1 TO 9
FOR d = 0 TO 9
cpd = INT(c ^ d + .5)
abcd = 1000 * a + 100 * b + 10 * c + d
n = apb * cpd - abcd
IF n >= 1 THEN
IF n < minn THEN
minn = n
minna = a: minnb = b: minnc = c: minnd = d
END IF
END IF
m = abcd - apb * cpd
IF m >= 2 THEN
IF m < minm THEN
minm = m
minma = a: minmb = b: minmc = c: minmd = d
END IF
END IF
NEXT d
NEXT c
NEXT b
NEXT a
PRINT minna; minnb; minnc; minnd, minn
PRINT minma; minmb; minmc; minmd, minm
finds
4 0 8 4 12
3 6 5 1 6
which means:
(i) 4084 = 4^0 * 8^4 - 12
(ii) 3651 = 3^6 * 5^1 + 6
|
Posted by Charlie
on 2012-10-27 14:02:41 |