OFFSET
0,6
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..200
MAPLE
g:= (n, s)-> `if`(n in s or not issqr(n), 0, 1):
b:= proc(u, o, t, s) option remember; `if`(u+o=0, g(t, s),
`if`(g(t, s)=1, add(b(u-j, o+j-1, 1, s union {t})
, j=1..u), 0)+ add(b(u+j-1, o-j, t+1, s), j=1..o))
end:
a:= n-> b(n, 0$2, {}):
seq(a(n), n=0..50);
MATHEMATICA
g[n_, s_] := If[MemberQ[s, n] || !IntegerQ@Sqrt[n], 0, 1];
b[u_, o_, t_, s_] := b[u, o, t, s] = If[u + o == 0, g[t, s],
If[g[t, s] == 1, Sum[b[u - j, o + j - 1, 1, s ~Union~ {t}],
{j, 1, u}], 0] + Sum[b[u + j - 1, o - j, t + 1, s], {j, 1, o}]];
a[n_] := b[n, 0, 0, {}];
Table[a[n], {n, 0, 50}] (* Jean-François Alcover, Jul 24 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jul 28 2018
STATUS
approved