login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 1
0, 1, 2, 10, 48, 295, 2068, 16654, 150382, 1508500, 16631696, 199966907, 2603709640, 36501212971, 548150650582, 8779185528284, 149376644391508, 2690852138104504, 51161190374132154, 1023850096381041159, 21512688329462044264 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
LINKS
FORMULA
a(n) = Sum_{k=1..floor(n/2)} k * A299789(n,k). - Alois P. Heinz, Jan 21 2019
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 *)
PROG
(C++) #include <iostream> #include <vector> #include <algorithm> using namespace std; inline int mabsj(const vector<int> & s) { const int n = s.size() ; int mi =n ; for(int i=0; i<n; i++) { const int thisdiff = abs(s[i]-i-1) ; if ( thisdiff < mi ) mi=thisdiff ; } return mi ; } int main(int argc, char *argv[]) { for(int n=1 ;; n++) { vector<int> s; for(int i=1; i<=n; i++) s.push_back(i) ; unsigned long long resul=0 ; do { resul += mabsj(s) ; } while( next_permutation(s.begin(), s.end()) ) ; cout << n << " " << resul << endl ; } return 0 ; } /* R. J. Mathar, Nov 01 2007 */
CROSSREFS
Sequence in context: A200540 A166922 A302557 * A037256 A270664 A330543
KEYWORD
more,nonn
AUTHOR
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
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 14:54 EDT 2024. Contains 371960 sequences. (Running on oeis4.)