OFFSET
1,5
COMMENTS
a(n) < n by definition, but if we counted the sum p_n + p_1, we could get a(n) = n for 32 <= n <= 49 (see A071984). - David Wasserman, Aug 20 2002
Can be formulated as a traveling salesman problem on a complete graph with node set {0, 1, ..., n} and edge cost -1 if i + j is a square, 0 otherwise. - Rob Pratt, Nov 07 2012
a(n) = n - 1 for 25 <= n <= 500, computed by solving corresponding TSP. - Rob Pratt, Nov 07 2012
REFERENCES
Bernardo Recamán Santos, Challenging Brainteasers, Sterling, NY, 2000, page 71, shows a(15) = 14 using 9,7,2,14,11,5,4,12,13,3,6,10,15,1,8.
EXAMPLE
n=8: take 2,7,8,1,3,6,4,5 to get 5 squares: 2+7, 8+1, 1+3, 3+6, 4+5; a(8) = 5.
(1,8,9,7,2,14,11,5,4,12,13,3,6,10) gives 12 squares and no permutation of (1..14) gives more, so a(14)=12.
MATHEMATICA
a[n_] := Which[n == 1, 0, n > 30, n - 1, True, tour = FindShortestTour[Range[n], DistanceFunction -> Function[{i, j}, If[IntegerQ[Sqrt[i + j]], -1, 0]]] // Last; cnt = 0; Do[If[IntegerQ[Sqrt[tour[[i]] + tour[[i + 1]]]], cnt++], {i, 1, n}]; cnt]; Table[an = a[n]; Print["a(", n, ") = ", an]; an, {n, 1, 69}] (* Jean-François Alcover, Nov 04 2016 *)
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
N. J. A. Sloane, Oct 23 2001
EXTENSIONS
More terms from Vladeta Jovovic, Oct 23 2001
More terms from John W. Layman and Charles K. Layman (cklayman(AT)juno.com), Nov 07 2001
More terms from David Wasserman, Aug 20 2002
More terms from Rob Pratt, Nov 07 2012
STATUS
approved