OFFSET
1,2
COMMENTS
At n = 6k +/- 1, there is a simple formula a(n) = n*(n+1)*(2n+1)/6 and set of squares is the first n squares {1..n}^2.
Companion sequence of minimal integral averages of n distinct squares is a(n)/n: 1, 5, 7, 21, 11, 26, 20, 30, 38, 47, 46, 72, 63, 84, 93, 101, 105, 123, 130, 163, 170, 186, 188, 216, 221, ... .
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..301
EXAMPLE
a(1) = 1 = 1^2 = 1*1.
a(2) = 10 = 1^2 + 3^2 = 2*5.
a(3) = 21 = 1^2 + 2^2 + 4^2 = 3*7.
a(4) = 84 = 1^2 + 3^2 + 5^2 + 7^2 = 4*21.
a(5) = 55 = 1^2 + 2^2 + 3^2 + 4^2 + 5^2 = 5*11.
MAPLE
b:= proc(n, i, t) option remember; local h; h:= t*(t+1)*(2*t+1)/6;
i>=t and n>=h and (n=h or t>0 and
(b(n, i-1, t) or i<=n and b(n-i^2, i-1, t-1)))
end:
a:= proc(n) local s;
for s from n*ceil((n+1)*(2*n+1)/6) by n
while not b(s, iroot(s, 2)+1, n)
do od; s
end:
seq(a(n), n=1..50); # Alois P. Heinz, Aug 16 2012
MATHEMATICA
$RecursionLimit = 2000;
b[n_, i_, t_] := b[n, i, t] = Module[{h = t(t+1)(2t+1)/6}, i >= t && n >= h && (n==h || t>0 && (b[n, i-1, t] || i <= n && b[n-i^2, i-1, t-1]))];
a[n_] := Module[{s}, For[s = n Ceiling[(n+1)(2n+1)/6], !b[s, Floor @ Sqrt[s] + 1, n], s += n]; s];
Array[a, 50] (* Jean-François Alcover, Nov 22 2020, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Zak Seidov, Aug 16 2012
EXTENSIONS
More terms from Alois P. Heinz, Aug 16 2012
STATUS
approved