A137782 a(n) = the number of permutations (p(1), p(2), ..., p(n)) of (1,2,...,n) where, for each k (2 <= k <= n), the sign of (p(k) - p(k-1)) equals the sign of (p(n+2-k) - p(n+1-k)).
1, 1, 2, 2, 12, 24, 200, 540, 6160, 21616, 306432, 1310880, 22338624, 113017696, 2245983168, 13108918368, 297761967360, 1969736890624, 50332737128960, 372125016868608, 10565549532009472, 86337114225206784, 2696451226217269248, 24132714802787013632
Offset: 0
Keywords
Examples
Consider the permutation (for n = 7): 3,6,7,5,1,2,4. The signs of the differences between adjacent terms form the sequence: ++--++, which has reflective symmetry. So this permutation, among others, is counted when n = 7.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..190
Crossrefs
Cf. A137783.
Programs
-
Maple
b:= proc(u, o, h) option remember; `if`(u+o=0, 1, add(add(b(u-j, o+j-1, h+i-1), i=1..u+o-h), j=1..u)+ add(add(b(u+j-1, o-j, h-i), i=1..h), j=1..o)) end: a:= proc(n) option remember; local r; `if`(irem(n, 2, 'r')=0, b(0, r$2)*binomial(n, r), add(add(binomial(j-1, i)*binomial(n-j, r-i)* b(r-i, i, n-j-r+i), i=0..min(j-1, r)), j=1..n)) end: seq(a(n), n=0..30); # Alois P. Heinz, Sep 15 2015
-
Mathematica
b[u_, o_, h_] := b[u, o, h] = If[u+o == 0, 1, Sum[Sum[b[u-j, o+j-1, h+i-1], {i, 1, u+o-h}], {j, 1, u}] + Sum[Sum[b[u+j-1, o-j, h-i], {i, 1, h}], {j, 1, o}]]; a[n_] := a[n] = Module[{r = Quotient[n, 2]}, If[Mod[n, 2] == 0, b[0, r, r]*Binomial[n, r], Sum[Sum[Binomial[j-1, i]*Binomial[n-j, r-i]*b[r-i, i, n-j-r+i], {i, 0, Min[j-1, r]}], {j, 1, n}]]]; Table[a[n], {n, 0, 30}] (* Jean-François Alcover, May 13 2019, after Alois P. Heinz *)
-
PARI
{ a(n) = local(r,u,c,t); r=0; forvec(v=vector(n-1,i,[2*i==n,1]), u=sum(i=1,#v,v[i]); c=sum(i=1,(n-1)\2,!v[i]&&!v[n-i]); t=[0]; for(i=1,#v,if(v[i],t=concat(t,[i]))); r += (-1)^u * 2^c * n! \ prod(i=2,#t,(t[i]-t[i-1])!) \ (n-t[ #t])! ); (-1)^(n+1)*r } \\ Max Alekseyev, May 06 2009
Formula
Extensions
First 8 terms calculated by Olivier Gérard
Extended by Max Alekseyev, May 06 2009
a(0), a(22) from Alois P. Heinz, Jul 02 2015
a(23) from Alois P. Heinz, Sep 15 2015
Comments