OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
EXAMPLE
a(1) = 1 = 1^2.
a(2) = 25 = 3^2 + 4^2.
a(3) = 9 = 1^2 + 2*2^2.
a(4) = 4 = 4*1^2.
a(5) = 16 = 3*1^2 + 2^2 + 3^2.
a(6) = 9 = 5*1^2 + 2^2.
a(7) = 16 = 4*1^2 + 3*2^2.
MAPLE
b:= proc(n, i, t) option remember; n>=t and (n=t or
(i>0 and (b(n, i-1, t) or i^2<=n and b(n-i^2, i, t-1))))
end:
a:= proc(n) option remember; local k;
for k while not b(k^2, k, n) do od; k^2
end:
seq(a(n), n=1..100); # Alois P. Heinz, Aug 26 2012
MATHEMATICA
b[n_, i_, t_] := b[n, i, t] = n >= t && (n == t || (i > 0 && (b[n, i - 1, t] || i^2 <= n && b[n - i^2, i, t - 1])));
a[n_] := a[n] = Module[{k}, For[k = 1, !b[k^2, k, n], k++]; k^2];
Array[a, 100] (* Jean-François Alcover, Nov 22 2020, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon Perry, Aug 15 2012
EXTENSIONS
More terms from Alois P. Heinz, Aug 26 2012
STATUS
approved