login
Number of 1 up, 2 down, 3 up, 4 down, ... permutations of [n].
4

%I #30 Mar 22 2021 15:00:06

%S 1,1,1,2,3,11,26,50,315,1168,3309,7910,78134,431354,1748956,5797168,

%T 16619603,239887424,1875375485,10496708022,47013492080,178807998112,

%U 599025922320,11965846097382,126883998286089,947079890934441,5574231845278396,27500583638094490

%N Number of 1 up, 2 down, 3 up, 4 down, ... permutations of [n].

%H Alois P. Heinz, <a href="/A229066/b229066.txt">Table of n, a(n) for n = 0..250</a>

%e a(2) = 1: 12.

%e a(3) = 2: 132, 231.

%e a(4) = 3: 1432, 2431, 3421.

%e a(5) = 11: 14325, 15324, 15423, 24315, 25314, 25413, 34215, 35214, 35412, 45213, 45312.

%e a(6) = 26: 143256, 153246, ..., 563124, 564123.

%e a(7) = 50: 1432567, 1532467, ..., 6741235, 6751234.

%e a(8) = 315: 14325687, 14325786, ..., 78613452, 78623451.

%p b:= proc(u, o, t, k) option remember; `if`(u+o=0, 1, add(`if`(t=k,

%p b(o-j, u+j-1, 1, k+1), b(u+j-1, o-j, t+1, k)), j=1..o))

%p end:

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

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

%t b[u_, o_, t_, k_] := b[u, o, t, k] = If[u + o == 0, 1, Sum[If[t == k, b[o - j, u + j - 1, 1, k + 1], b[u + j - 1, o - j, t + 1, k]], {j, 1, o}]];

%t a[n_] := b[0, n, 0, 1];

%t a /@ Range[0, 35] (* _Jean-François Alcover_, Mar 22 2021, after _Alois P. Heinz_ *)

%Y Cf. A227941, A229551, A229892.

%K nonn,eigen

%O 0,4

%A _Alois P. Heinz_, Oct 02 2013