%I #23 Sep 05 2021 05:39:45
%S 0,1,1,3,4,34,70,853,2365,36369,125870,2367212,9829820,218570717,
%T 1058927507,27167018427,150421002736,4373595961678,27243141998506,
%U 885304614118777,6127294825424317,220074660203753961,1675478215412320154,65909583942401516528,547401364007816870552,23406034074310130665241
%N Number of permutations of n letters that have all valleys even and all peaks odd and that end with an ascent.
%H Alois P. Heinz, <a href="/A246015/b246015.txt">Table of n, a(n) for n = 0..470</a> (first 101 terms from N. J. A. Sloane)
%H Ira M. Gessel and Yan Zhuang, <a href="http://arxiv.org/abs/1408.1886">Counting permutations by alternating descents</a>, arXiv:1408.1886 [math.CO], 2014. See g(n).
%F See Maple code for recurrence involving A246012(n) = f(n).
%p Gf1:= (3*sin(x/2)+3*cosh(sqrt(3)*x/2))/(3*cos(x/2)-sqrt(3)*sinh(sqrt(3)*x/2));
%p t1:=series(Gf1,x,40):
%p t2:=SERIESTOLISTMULT(t1);
%p f:=n->t2[n+1]; # this is f(n), A246012
%p g:=proc(n) global f; option remember; local m,s,k; m:=n-1;
%p if n=0 then 0 else
%p s:=add(binomial(m,2*k)*f(2*k)*(f(m-2*k)-g(m-2*k)),k=0..floor((m-2)/2));
%p if m mod 2 = 0 then s+f(m) else s+g(m); fi;
%p fi; end;
%p [seq(g(n),n=0..30)];
%p # second Maple program:
%p b:= proc(u, o, p, t) option remember; `if`(u+o=0, t,
%p `if`(t=0 or p=1, add(b(u-j, o+j-1, 1-p, 0), j=1..u), 0)+
%p `if`(t=1 or p=0, add(b(u+j-1, o-j, 1-p, 1), j=1..o), 0))
%p end:
%p a:= n-> b(0, n, 0$2):
%p seq(a(n), n=0..25); # _Alois P. Heinz_, Aug 03 2018
%t f[n_] := SeriesCoefficient[(3*Cosh[(Sqrt[3]*x)/2] + 3*Sin[x/2])/(3*Cos[x/2] - Sqrt[3]*Sinh[(Sqrt[3]*x)/2]), {x, 0, n}]*n!;
%t g[n_] := g[n] = Module[{m, s, k}, m = n-1; If[n == 0, 0, s = Sum[ Binomial[ m, 2*k]*f[2*k]*(f[m-2*k] - g[m-2*k]), {k, 0, Floor[(m-2)/2]}]; If[EvenQ[m], s + f[m], s + g[m]]]];
%t Table[g[n], {n, 0, 30}] (* _Jean-François Alcover_, Jan 23 2018, translated from Maple *)
%Y Cf. A246012.
%K nonn
%O 0,4
%A _N. J. A. Sloane_, Aug 11 2014