%I
%S 1,0,1,0,1,1,0,2,3,1,2,4,11,6,1,16,18,40,35,10,1,104,142,178,195,85,
%T 15,1,688,1236,1106,1148,665,175,21,1,5116,10832,9300,7728,5173,1820,
%U 322,28,1,44224,98492,91680,63284,42168,18165,4284,546,36,1,438560,964172,974924,627420,378620,181797,53361,9030,870,45,1
%N Triangle read by rows: T(n,k) is the number of permutations of [n] having k cycles with at most 2 alternating runs (it is assumed that the smallest element of the cycle is in the first position), 0<=k<=n.
%C Sum of entries in row n is n!.
%C T(n,0) = A187248(n).
%C Sum(k*T(n,k),k>=0) = A187249(n).
%H Alois P. Heinz, <a href="/A187247/b187247.txt">Rows n = 0..140, flattened</a>
%F E.g.f.: G(t,z) = exp[(1/4)(t1)(2z  1 + exp(2z))]/(1z).
%F The 4variate g.f. H(u,v,w,z) (exponential with respect z), where u marks number of cycles with 1 alternating run, v marks number of cycles with 2 alternating runs, w marks the number of all cycles, and z marks the size of the permutation, is given by
%F H(u,v,w,z) = exp[(1/4)w((v1)(exp(2z)+2z)+4(uv)exp(z)+14u+3v)]/(1z)^w.
%F We have G(t,z) = H(t,t,1,z).
%e T(3,2)=3 because we have (1)(23), (12)(3), and (13)(2).
%e T(4,0)=2 because we have (1423) and (1324).
%e T(4,1)=4 because we have (1234), (1243), (1342), and (1432).
%e Triangle starts:
%e 1;
%e 0,1;
%e 0,1,1;
%e 0,2,3,1;
%e 2,4,11,6,1;
%e 16,18,40,35,10,1;
%p G := exp((1/4)*(t1)*(2*z1+exp(2*z)))/(1z): Gser := simplify(series(G, z = 0, 15)): for n from 0 to 13 do P[n] := sort(expand(factorial(n) * coeff(Gser, z, n))) end do: for n from 0 to 10 do seq(coeff(P[n], t, k), k = 0 .. n) end do; # yields sequence in triangular form
%p # second Maple program:
%p b:= proc(n) option remember; expand(
%p `if`(n=0, 1, add(b(nj)*binomial(n1, j1)*
%p `if`(j=1, x, (j1)!+2^(j2)*(x1)), j=1..n)))
%p end:
%p T:= n> (p> seq(coeff(p, x, i), i=0..n))(b(n)):
%p seq(T(n), n=0..12); # _Alois P. Heinz_, Apr 15 2017
%t b[n_] := b[n] = Expand[If[n==0, 1, Sum[b[nj]*Binomial[n1, j1]*If[j==1, x, (j1)! + 2^(j2)*(x1)], {j, 1, n}]]];
%t T[n_] := Function[p, Table[Coefficient[p, x, i], {i, 0, n}]][b[n]];
%t Table[T[n], {n, 0, 12}] // Flatten (* _JeanFrançois Alcover_, May 18 2017, after _Alois P. Heinz_ *)
%Y Cf. A187248, A187249.
%K nonn,tabl
%O 0,8
%A _Emeric Deutsch_, Mar 07 2011
