%I #54 Aug 01 2023 12:17:09
%S 1,1,1,1,1,1,5,20,55,125,251,2300,15775,70500,249250,750751,10006375,
%T 97226875,601638125,2886735625,11593285251,202808749375,2550175096250,
%U 20163891580625,122209131374375,613498040952501,13287626090593750,205055676105734375
%N Number of 5-alternating permutations.
%C For an integer n>0, a permutation s = s_1...s_k is a n-alternating permutation if it has the property that s_i < s_{i+1} if and only if n divides i.
%D Anthony Mendes and Jeffrey Remmel, Generating functions from symmetric functions, Preliminary version of book, available from Jeffrey Remmel's home page.
%H Alois P. Heinz, <a href="/A181936/b181936.txt">Table of n, a(n) for n = 0..200</a>
%H R. J. Cano, <a href="http://oeis.org/w/images/0/01/AltSeq_A181936.txt">PARI Sequencer program</a>.
%H Peter Luschny, <a href="http://oeis.org/wiki/User:Peter_Luschny/SeidelTransform">An old operation on sequences: the Seidel transform</a>.
%H Ludwig Seidel, <a href="https://babel.hathitrust.org/cgi/pt?id=hvd.32044092897461&view=1up&seq=176">Über eine einfache Entstehungsweise der Bernoulli'schen Zahlen und einiger verwandten Reihen</a>, Sitzungsberichte der mathematisch-physikalischen Classe der königlich bayerischen Akademie der Wissenschaften zu München, volume 7 (1877), 157-187. [USA access only through the <a href="https://www.hathitrust.org/accessibility">HATHI TRUST Digital Library</a>]
%H Ludwig Seidel, <a href="https://www.zobodat.at/pdf/Sitz-Ber-Akad-Muenchen-math-Kl_1877_0157-0187.pdf">Über eine einfache Entstehungsweise der Bernoulli'schen Zahlen und einiger verwandten Reihen</a>, Sitzungsberichte der mathematisch-physikalischen Classe der königlich bayerischen Akademie der Wissenschaften zu München, volume 7 (1877), 157-187. [Access through <a href="https://de.wikipedia.org/wiki/ZOBODAT">ZOBODAT</a>]
%p A181936_list := proc(dim) local E,DIM,n,k;
%p DIM := dim-1; E := array(0..DIM, 0..DIM); E[0,0] := 1;
%p for n from 1 to DIM do
%p if n mod 5 = 0 then E[n,0] := 0 ;
%p for k from n-1 by -1 to 0 do E[k,n-k] := E[k+1,n-k-1] + E[k,n-k-1] od;
%p else E[0,n] := 0;
%p for k from 1 by 1 to n do E[k,n-k] := E[k-1,n-k+1] + E[k-1,n-k] od;
%p fi od; [E[0,0],seq(E[k,0]+E[0,k],k=1..DIM)] end:
%p A181936_list(28);
%p # Alternatively, using an exponential generating function:
%p A181936_list := proc(n) local H,F,i; H := (r,s) -> hypergeom(r,s/5,-(t/5)^5);
%p F := t -> 1+(t^5*H([1],[6,7,8,9,10])+5*t^4*H([],[6,7,8,9])+20*t^3*H([],[4,6,7,8])+60*t^2*H([],[3,4,6,7])+120*t^1*H([],[2,3,4,6]))/(120*H([],[2,3,4,1])); seq(i!*coeff(series(F(t),t,n+1),t,i),i=0..n-1) end:
%t dim = 27; e[0, 0] = 1; e[n_ /; Mod[n, 5] == 0 && 0 <= n <= dim, 0] = 0; e[k_ /; 0 <= k <= dim, n_ /; 0 <= n <= dim] /; Mod[n+k, 5] == 0 := e[k, n] = e[k, n-1] + e[k+1, n-1]; e[0, n_ /; Mod[n, 5] == 0 && 0 <= n <= dim] = 0; e[k_ /; 0 <= k <= dim, n_ /; 0 <= n <= dim] /; Mod[n+k, 5] != 0 := e[k, n] = e[k-1, n] + e[k-1, n+1]; e[_, _] = 0; a[0] = 1; a[n_] := e[n, 0] + e[0, n]; Table[a[n], {n, 0, dim}] (* _Jean-François Alcover_, Jun 27 2013, translated and adapted from Maple *)
%t b[u_, o_, t_] := b[u, o, t] = If[u + o == 0, 1, If[t == 0,
%t Sum[b[u - j, o + j - 1, Mod[t + 1, 5]], {j, 1, u}],
%t Sum[b[u + j - 1, o - j, Mod[t + 1, 5]], {j, 1, o}]]];
%t a[n_] := b[n, 0, 0];
%t a /@ Range[0, 35] (* _Jean-François Alcover_, Apr 21 2021, after _Alois P. Heinz_ in A250283 *)
%t nmax = 30; CoefficientList[Series[1 + Sum[(x^(5 - k) * HypergeometricPFQ[{1}, {6/5 - k/5, 7/5 - k/5, 8/5 - k/5, 9/5 - k/5, 2 - k/5}, -x^5/3125])/(5 - k)!, {k, 0, 4}] / HypergeometricPFQ[{}, {1/5, 2/5, 3/5, 4/5}, -x^5/3125], {x, 0, nmax}], x] * Range[0, nmax]! (* _Vaclav Kotesovec_, Apr 21 2021 *)
%o (Sage)
%o @cached_function
%o def A(m,n):
%o if n == 0: return 1
%o s = -1 if m.divides(n) else 1
%o t = [m*k for k in (0..(n-1)//m)]
%o return s*add(binomial(n,k)*A(m,k) for k in t)
%o A181936 = lambda n: (-1)^int(is_odd(n//5))*A(5,n)
%o print([A181936(n) for n in (0..30)]) # _Peter Luschny_, Jan 24 2017
%Y Number of m-alternating permutations: A000012 (m=1), A000111 (m=2), A178963 (m=3), A178964 (m=4), this sequence (m=5), A250283 (m=6), A250284 (m=7), A250285 (m=8), A250286 (m=9), A250287 (m=10).
%Y Row n=5 of A181937.
%K nonn
%O 0,7
%A _Peter Luschny_, Apr 03 2012