|
Search: id:A129118
|
|
|
| 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
|
|
| 0, 1, 2, 10, 48, 295, 2068, 16654, 150382, 1508500, 16631696, 199966907, 2603709640
(list; graph; listen)
|
|
|
OFFSET
|
1,3
|
|
|
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 (deutsch(AT)duke.poly.edu), Aug 24 2007
|
|
PROGRAM
|
(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 (mathar(AT)strw.leidenuniv.nl), Nov 01 2007
|
|
CROSSREFS
|
Cf. A130153, A018927.
Sequence in context: A086853 A036918 A166922 this_sequence A037256 A052576 A143147
Adjacent sequences: A129115 A129116 A129117 this_sequence A129119 A129120 A129121
|
|
KEYWORD
|
more,nonn
|
|
AUTHOR
|
Emeric Deutsch, Vladeta Jovovic (vladeta(AT)eunet.rs), Jun 07 2007
|
|
EXTENSIONS
|
One more term from Emeric Deutsch (deutsch(AT)duke.poly.edu), Aug 24 2007
a(11)-a(13) from R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Nov 01 2007
|
|
|
Search completed in 0.002 seconds
|