Three 3-digit non leading zero positive base N integers
P,
Q
and
R, with
P >
Q >
R, are such that:
- Q is the geometric mean of P and R, and:
- P, Q and R can be derived from one another by
cyclic permutation of digits.
Determine all possible positive integer values of N < 30 for which this is possible.
(In reply to
computer solution for N<=100 by Charlie)
DEFDBL A-Z
CLS
FOR n = 2 TO 100
n2 = n * n
FOR a = 1 TO n - 1
FOR b = 1 TO n - 1
FOR c = 1 TO n - 1
p = a * n2 + b * n + c
q = b * n2 + c * n + a
r = c * n2 + a * n + b
IF p > q AND q > r THEN
a2 = b: b2 = c: c2 = a
a3 = c: b3 = a: c3 = b
GOSUB report
END IF
SWAP q, r
IF p > q AND q > r THEN
a2 = c: b2 = a: c2 = b
a3 = b: b3 = c: b3 = a
GOSUB report
END IF
NEXT
NEXT
NEXT
NEXT n
END
report:
IF q * q = p * r THEN
PRINT USING "### ## ## ## ## ## ## ## ## ## ######## ######## ########"; n; a; b; c; a2; b2; c2; a3; b3; c3; p; q; r
ct = ct + 1
IF ct MOD 40 = 0 THEN DO: LOOP UNTIL INKEY$ > "": PRINT
END IF
RETURN
|
Posted by Charlie
on 2009-07-04 16:05:28 |