The set of numbers {4,7,9,10,12,14} contains three arithmetic sequences of three terms, {4,7,10}, {10,12,14}, and {4,9,14}. Find a set of six perfect squares with that property. All the perfect squares should be greater than 1 and none should be equal to each other.
(In reply to
Smaller solution by goFish)
The following program, taking squares through 31^2 = 961, finds only goFish's solution:
DIM sq(31), used(961)
FOR i = 2 TO 31
sq(i) = i * i
NEXT
FOR s1 = 2 TO 26
s(1) = sq(s1)
used(s(1)) = 1
FOR s2 = s1 + 1 TO 27
s(2) = sq(s2)
used(s(2)) = 1
FOR s3 = s2 + 1 TO 28
s(3) = sq(s3)
used(s(3)) = 1
FOR s4 = s3 + 1 TO 29
s(4) = sq(s4)
used(s(4)) = 1
FOR s5 = s4 + 1 TO 30
s(5) = sq(s5)
used(s(5)) = 1
FOR s6 = s5 + 1 TO 31
s(6) = sq(s6)
used(s(6)) = 1
prog = 0
FOR m1 = 1 TO 4
FOR m2 = m1 + 1 TO 5
sq3 = 2 * s(m2) - s(m1)
IF sq3 <= 961 THEN
IF used(sq3) THEN
prog = prog + 1
END IF
END IF
NEXT
NEXT
IF prog >= 3 THEN
FOR i = 1 TO 6
PRINT s(i);
NEXT
PRINT " "; prog
END IF
used(s(6)) = 0
NEXT
used(s(5)) = 0
NEXT
used(s(4)) = 0
NEXT
used(s(3)) = 0
NEXT
used(s(2)) = 0
NEXT
used(s(1)) = 0
NEXT
|
Posted by Charlie
on 2005-11-20 12:38:57 |