OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..464
FORMULA
a(n) = A262124(n,2).
EXAMPLE
a(0) = 1: the empty permutation.
a(1) = 1: 1.
a(2) = 1: 12.
a(3) = 3: 123, 132, 231.
a(4) = 8: 1243, 1324, 1342, 1423, 2314, 2341, 2413, 3412.
MAPLE
b:= proc(u, o, c) option remember; `if`(c<0 or c>2, 0, `if`(u+o=0, x^c,
(p-> add(coeff(p, x, i)*x^max(i, c), i=0..2))(add(
b(u-j, o-1+j, c-1), j=1..u)+add(b(u+j-1, o-j, c+1), j=1..o))))
end:
a:= n-> `if`(n=0, 1, (p-> add(coeff(p, x, i), i=0..2))(
add(b(j-1, n-j, 0), j=1..n))):
seq(a(n), n=0..30);
MATHEMATICA
b[u_, o_, c_] := b[u, o, c] = If[c < 0 || c > 2, 0, If[u + o == 0, x^c, Function[p, Sum[Coefficient[p, x, i]*x^Max[i, c], {i, 0, 2}]][Sum[b[u - j, o - 1 + j, c - 1], {j, u}] + Sum[b[u + j - 1, o - j, c + 1], {j, o}]]]];
a[n_] := If[n == 0, 1, Function[p, Sum[Coefficient[p, x, i], {i, 0, 2}]][Sum[b[j - 1, n - j, 0], {j, n}]]];
Table[a[n], {n, 0, 30}] (* Jean-François Alcover, Aug 30 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Sep 11 2015
STATUS
approved