A348615 Number of non-alternating permutations of {1...n}.
0, 0, 0, 2, 14, 88, 598, 4496, 37550, 347008, 3527758, 39209216, 473596070, 6182284288, 86779569238, 1303866853376, 20884006863710, 355267697410048, 6397563946377118, 121586922638606336, 2432161265800164950, 51081039175603191808, 1123862030028821404198
Offset: 0
Keywords
Examples
The a(4) = 14 permutations: (1,2,3,4) (3,1,2,4) (1,2,4,3) (3,2,1,4) (1,3,4,2) (3,4,2,1) (1,4,3,2) (4,1,2,3) (2,1,3,4) (4,2,1,3) (2,3,4,1) (4,3,1,2) (2,4,3,1) (4,3,2,1)
Links
- Wikipedia, Alternating permutation
Crossrefs
Programs
-
Maple
b:= proc(u, o) option remember; `if`(u+o=0, 1, add(b(o-1+j, u-j), j=1..u)) end: a:= n-> n!-`if`(n<2, 1, 2)*b(n, 0): seq(a(n), n=0..30); # Alois P. Heinz, Nov 04 2021
-
Mathematica
wigQ[y_]:=Or[Length[y]==0,Length[Split[y]] ==Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1]; Table[Length[Select[Permutations[Range[n]],!wigQ[#]&]],{n,0,6}]
-
Python
from itertools import accumulate, count, islice def A348615_gen(): # generator of terms yield from (0,0) blist, f = (0,2), 1 for n in count(2): f *= n yield f - (blist := tuple(accumulate(reversed(blist),initial=0)))[-1] A348615_list = list(islice(A348615_gen(),40)) # Chai Wah Wu, Jun 09-11 2022
Formula
a(n) = n! - A001250(n).
Comments