cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A348615 Number of non-alternating permutations of {1...n}.

This page as a plain text file.
%I A348615 #17 Jun 11 2022 11:43:08
%S A348615 0,0,0,2,14,88,598,4496,37550,347008,3527758,39209216,473596070,
%T A348615 6182284288,86779569238,1303866853376,20884006863710,355267697410048,
%U A348615 6397563946377118,121586922638606336,2432161265800164950,51081039175603191808,1123862030028821404198
%N A348615 Number of non-alternating permutations of {1...n}.
%C A348615 A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either.
%C A348615 Also permutations of {1...n} matching the consecutive patterns (1,2,3) or (3,2,1). Matching only one of these gives A065429.
%H A348615 Wikipedia, <a href="https://en.wikipedia.org/wiki/Alternating_permutation">Alternating permutation</a>
%F A348615 a(n) = n! - A001250(n).
%e A348615 The a(4) = 14 permutations:
%e A348615   (1,2,3,4)  (3,1,2,4)
%e A348615   (1,2,4,3)  (3,2,1,4)
%e A348615   (1,3,4,2)  (3,4,2,1)
%e A348615   (1,4,3,2)  (4,1,2,3)
%e A348615   (2,1,3,4)  (4,2,1,3)
%e A348615   (2,3,4,1)  (4,3,1,2)
%e A348615   (2,4,3,1)  (4,3,2,1)
%p A348615 b:= proc(u, o) option remember;
%p A348615       `if`(u+o=0, 1, add(b(o-1+j, u-j), j=1..u))
%p A348615     end:
%p A348615 a:= n-> n!-`if`(n<2, 1, 2)*b(n, 0):
%p A348615 seq(a(n), n=0..30);  # _Alois P. Heinz_, Nov 04 2021
%t A348615 wigQ[y_]:=Or[Length[y]==0,Length[Split[y]] ==Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1];
%t A348615 Table[Length[Select[Permutations[Range[n]],!wigQ[#]&]],{n,0,6}]
%o A348615 (Python)
%o A348615 from itertools import accumulate, count, islice
%o A348615 def A348615_gen(): # generator of terms
%o A348615     yield from (0,0)
%o A348615     blist, f = (0,2), 1
%o A348615     for n in count(2):
%o A348615         f *= n
%o A348615         yield f - (blist := tuple(accumulate(reversed(blist),initial=0)))[-1]
%o A348615 A348615_list = list(islice(A348615_gen(),40)) # _Chai Wah Wu_, Jun 09-11 2022
%Y A348615 The complement is counted by A001250, ranked by A333218.
%Y A348615 The complementary version for compositions is A025047, ranked by A345167.
%Y A348615 A directed version is A065429, complement A049774.
%Y A348615 The version for compositions is A345192, ranked by A345168.
%Y A348615 The version for ordered factorizations is A348613, complement A348610.
%Y A348615 A345165 counts partitions w/o an alternating permutation, ranked by A345171.
%Y A348615 A345170 counts partitions w/ an alternating permutation, ranked by A345172.
%Y A348615 A348379 counts factorizations with an alternating permutation.
%Y A348615 A348380 counts factorizations without an alternating permutation.
%Y A348615 Cf. A056986, A102726, A325534, A325535, A344614, A344653, A344654, A347050, A347706, A348377, A348609.
%K A348615 nonn
%O A348615 0,4
%A A348615 _Gus Wiseman_, Nov 03 2021