DEFDBL A-Z
CLS
FOR a = 100 TO 998
a2 = a * a: IF a2 > 99999 THEN EXIT FOR
s$ = LTRIM$(STR$(a2))
good = 1
FOR i = 1 TO 4
FOR j = i + 1 TO 5
IF MID$(s$, i, 1) = MID$(s$, j, 1) THEN good = 0: EXIT FOR
NEXT
IF good = 0 THEN EXIT FOR
NEXT
IF good THEN
FOR b = a + 1 TO 999
b2 = b * b: IF b2 > 99999 THEN EXIT FOR
c2 = a2 + b2: IF c2 > 99999 THEN EXIT FOR
sr = INT(SQR(c2) + .5)
IF sr * sr = c2 THEN
s$ = LTRIM$(STR$(b2))
s1$ = LTRIM$(STR$(c2))
good = 1
FOR i = 1 TO 4
FOR j = i + 1 TO 5
IF MID$(s1$, i, 1) = MID$(s1$, j, 1) THEN good = 0: EXIT FOR
IF MID$(s$, i, 1) = MID$(s$, j, 1) THEN good = 0: EXIT FOR
NEXT
IF good = 0 THEN EXIT FOR
NEXT
IF good THEN
PRINT a2, b2, c2
PRINT a, b, sr
PRINT
END IF
END IF
NEXT b
END IF
NEXT a
finds
18496 74529 93025
136 273 305
with the 5-digit squares on top and A, B and C below. Note that the program doesn't check that all 10 digits have been used, but the answer is still unique.
|
Posted by Charlie
on 2009-12-06 21:44:55 |