login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons 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

Table of n, a(n) for n=1..21.

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

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

Cf. A130153, A018927, A299789.

Sequence in context: A200540 A166922 A302557 * A037256 A270664 A330543

Adjacent sequences:  A129115 A129116 A129117 * A129119 A129120 A129121

KEYWORD

more,nonn

AUTHOR

Emeric Deutsch, Vladeta Jovovic, Jun 07 2007

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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 20:01 EDT 2020. Contains 333103 sequences. (Running on oeis4.)