login
Number of n X n upper triangular matrices (m_{i,j}) of nonnegative integers with (Sum_{j=h..n} m_{h,j} - Sum_{i=1..h-1} m_{i,h}) in {-1,+1} for all h in {1,...,n}.
1

%I #13 Nov 18 2023 08:01:00

%S 1,1,3,13,91,957,14883,335685,10809115,489983429,30878036187,

%T 2674610665285,315157973368499,50044685318592821,10616892819871806779,

%U 2985356872553448786917,1104511676749585428665683,534037023412133157982099237,335321015907953576212969151451

%N Number of n X n upper triangular matrices (m_{i,j}) of nonnegative integers with (Sum_{j=h..n} m_{h,j} - Sum_{i=1..h-1} m_{i,h}) in {-1,+1} for all h in {1,...,n}.

%H Alois P. Heinz, <a href="/A257661/b257661.txt">Table of n, a(n) for n = 0..22</a>

%e a(2) = 3: [1,0; 0,1], [0,1; 0,0], [0,1; 0,2].

%p b:= proc(n, i, l) option remember; (m-> `if`(m=0, 1,

%p `if`(i=0, b(l[1]+1, m-1, subsop(1=NULL, l))+

%p `if`(l[1]=0, 0, b(l[1]-1, m-1, subsop(1=NULL, l))),

%p add(b(n-j, i-1, subsop(i=l[i]+j, l)), j=0..n))))(nops(l))

%p end:

%p a:= n-> b(1, n-1, [0$(n-1)]):

%p seq(a(n), n=0..14);

%t b[n_, i_, l_] := b[n, i, l] = With[{m = Length[l]}, If[m == 0, 1, If[i == 0, b[l[[1]] + 1, m - 1, ReplacePart[l, 1 -> Nothing]] + If[l[[1]] == 0, 0, b[l[[1]] - 1, m - 1, ReplacePart[l, 1 -> Nothing]]], Sum[b[n - j, i - 1, ReplacePart[l, i -> l[[i]] + j]], {j, 0, n}]]]];

%t a[n_] := b[1, n - 1, Table[0, {n - 1}]];

%t Table[a[n], {n, 0, 20}] (* _Jean-François Alcover_, Nov 18 2023, after _Alois P. Heinz_ *)

%Y Cf. A008608, A259844.

%K nonn

%O 0,3

%A _Alois P. Heinz_, Jul 12 2015