A129118 For each permutation p of {1,2,...,n} define minabsjump(p) = min(|p(i) - i|, 1<=i<=n); a(n) is the sum of minabsjumps of all p.
0, 1, 2, 10, 48, 295, 2068, 16654, 150382, 1508500, 16631696, 199966907, 2603709640, 36501212971, 548150650582, 8779185528284, 149376644391508, 2690852138104504, 51161190374132154, 1023850096381041159, 21512688329462044264
Offset: 1
Programs
-
Maple
n:=8; with(combinat); P:=permute(n); ct:= 0; for j to factorial(n) do ct:= ct+min(seq(abs(P[j][i]-i),i=1..n)) end do: ct; # yields a(n) for the specified n - Emeric Deutsch, Aug 24 2007 # second Maple program: b:= proc(s) option remember; (n-> `if`(n=1, x^(s[]-1), add((p-> add(coeff(p, x, i)*x^min(i, abs(n-j)), i=0..degree(p)))( b(s minus {j})), j=s)))(nops(s)) end: a:= n-> (p-> add(coeff(p, x, i)*i, i=1..n-1))(b({$1..n})): seq(a(n), n=1..15); # Alois P. Heinz, Jan 21 2019
-
Mathematica
b[s_] := b[s] = Function[n, If[n == 1, x^(s - 1), Sum[Function[p, Sum[ SeriesCoefficient[p, {x, 0, i}]*x^Min[i, Abs[n - j]], {i, 0, Exponent[p, x]}]][b[s ~Complement~ {j}]], {j, s}]]][Length[s]] // Expand; a[n_] := a[n] = If[n == 1, 0, Function[p, Sum[SeriesCoefficient[p, {x, 0, i}]*i, {i, 1, n - 1}]][b[Range[n]][[1]]]]; Table[Print[n, " ", a[n]]; a[n], {n, 1, 12}] (* Jean-François Alcover, May 21 2020, after 2nd Maple program *)
Formula
a(n) = Sum_{k=1..floor(n/2)} k * A299789(n,k). - Alois P. Heinz, Jan 21 2019
Extensions
One more term from Emeric Deutsch, Aug 24 2007
a(11)-a(13) from R. J. Mathar, Nov 01 2007
a(14) from Donovan Johnson, Sep 24 2010
a(15)-a(21) from Alois P. Heinz, Jan 21 2019