The only 5-digit triangular numbers of the form THREE are:
15400
17955
27966
40755
58311
75466
79800
84255
95266
Only 27966 consists of digits such that two of the other numbers contain no digits in common with it, and therefore 27966 is Dick's number, with 15400 and 58311 being the other two numbers.
adder = 1
DO
triNum = triNum + adder
adder = adder + 1
n$ = LTRIM$(STR$(triNum))
IF LEN(n$) = 5 THEN
IF INSTR(2, n$, MID$(n$, 1, 1)) = 0 THEN
IF INSTR(3, n$, MID$(n$, 2, 1)) = 0 THEN
IF INSTR(4, n$, MID$(n$, 3, 1)) = 0 THEN
IF MID$(n$, 4, 1) = MID$(n$, 5, 1) THEN
PRINT n$
ct = ct + 1: tn$(ct) = n$
END IF
END IF
END IF
END IF
END IF
LOOP UNTIL LEN(n$) > 5
PRINT
FOR i = 1 TO ct
goodCt = 0
REDIM m$(10)
FOR j = 1 TO ct
good = 1
FOR k = 1 TO 5
IF INSTR(tn$(j), MID$(tn$(i), k, 1)) > 0 THEN good = 0: EXIT FOR
NEXT
IF good THEN goodCt = goodCt + 1: m$(goodCt) = tn$(j)
NEXT
IF goodCt > 1 THEN
PRINT tn$(i),
FOR j = 1 TO goodCt
PRINT m$(j),
NEXT
PRINT
END IF
NEXT i
Adapted from Enigma No. 1510, "Triangular threesome", by Richard England, New Scientist, 6 September 2008. |