A216837 Number of permutations p of {1,...,n} such that at most one element of {p(1),...,p(i-1)} is between p(i) and p(i+1) for all i from 1 to n-1.
1, 1, 2, 6, 20, 72, 268, 1020, 3936, 15332, 60112, 236780, 935848, 3708236, 14721912, 58533264, 232991656, 928261480, 3700935760, 14763921580, 58924038816, 235258847064, 939576469152, 3753419774180, 14997257109992, 59933657096280, 239547378220840
Offset: 0
Keywords
Examples
a(4) = 20 = 4! - 4, because 4 permutations of {1,...,4} do not satisfy the condition: 2314, 2341, 3214, 3241.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..1000
Crossrefs
Programs
-
Maple
b:= proc(u, o) option remember; `if`(u+o=0, 1, add(b(sort([o-j, u+j-1])[]), j=1..min(2, o))+ add(b(sort([u-j, o+j-1])[]), j=1..min(2, u))) end: a:= n-> `if`(n=0, 1, add(b(sort([j-1, n-j])[]), j=1..n)): seq(a(n), n=0..35);
-
Mathematica
b[u_, o_] := b[u, o] = If[u+o == 0, 1, Sum[b[Sequence @@ Sort[{o-j, u+j-1}]], {j, 1, Min[2, o]}] + Sum[b[Sequence @@ Sort[{u-j, o+j-1}]], {j, 1, Min[2, u]}]]; a[n_] := If[n == 0, 1, Sum[b[Sequence @@ Sort[{j-1, n-j}]], {j, 1, n}]]; Table[a[n], {n, 0, 35}] (* Jean-François Alcover, Feb 05 2015, after Alois P. Heinz *)
Formula
a(n) ~ c * 4^n, where c = 0.052940679853652794231561081876002147090052503777... - Vaclav Kotesovec, Feb 23 2014
a(n) = Sum_{k=0..n-1} A356692(n-1,k) for n >= 1. - Alois P. Heinz, Aug 28 2022