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

%I #24 May 21 2020 09:57:51

%S 0,1,2,10,48,295,2068,16654,150382,1508500,16631696,199966907,

%T 2603709640,36501212971,548150650582,8779185528284,149376644391508,

%U 2690852138104504,51161190374132154,1023850096381041159,21512688329462044264

%N 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.

%F a(n) = Sum_{k=1..floor(n/2)} k * A299789(n,k). - _Alois P. Heinz_, Jan 21 2019

%p 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

%p # second Maple program:

%p b:= proc(s) option remember; (n-> `if`(n=1, x^(s[]-1), add((p->

%p add(coeff(p, x, i)*x^min(i, abs(n-j)), i=0..degree(p)))(

%p b(s minus {j})), j=s)))(nops(s))

%p end:

%p a:= n-> (p-> add(coeff(p, x, i)*i, i=1..n-1))(b({$1..n})):

%p seq(a(n), n=1..15); # _Alois P. Heinz_, Jan 21 2019

%t 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;

%t 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]]]];

%t Table[Print[n, " ", a[n]]; a[n], {n, 1, 12}] (* _Jean-François Alcover_, May 21 2020, after 2nd Maple program *)

%o (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 */

%Y Cf. A130153, A018927, A299789.

%K more,nonn

%O 1,3

%A _Emeric Deutsch_, _Vladeta Jovovic_, Jun 07 2007

%E One more term from _Emeric Deutsch_, Aug 24 2007

%E a(11)-a(13) from _R. J. Mathar_, Nov 01 2007

%E a(14) from _Donovan Johnson_, Sep 24 2010

%E a(15)-a(21) from _Alois P. Heinz_, Jan 21 2019

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 August 12 17:30 EDT 2024. Contains 375113 sequences. (Running on oeis4.)