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!)
A131529 Number of permutations of {1,2,...n} for which differences of adjacent numbers are all distinct. 4

%I #19 Mar 08 2015 18:24:16

%S 1,2,4,12,44,176,788,3936,23264,152112,1104876,8725320,74715908,

%T 687915040,6782261964,71294227456,796138700016,9409401651840,

%U 117378774461812

%N Number of permutations of {1,2,...n} for which differences of adjacent numbers are all distinct.

%H Joerg Arndt, <a href="/A131529/a131529.txt">lexicopraphically first permutation</a> with distinct differences for n=1..30 (permutations of {0,1,2,..,n-1}, i.e., zero based).

%o (C++) /* gcc -O2 -Wall -lstdc++ A131529.cc */

%o #include <iostream>

%o #include <vector>

%o #include <set>

%o #include <algorithm>

%o using namespace std;

%o inline int k(const vector<int> & s)

%o {

%o const int n = s.size();

%o set<int> diffs;

%o for (int i=1; i<n; i++)

%o {

%o const int thisdiff = s[i]-s[i-1];

%o if ( diffs.find(thisdiff) != diffs.end() ) return 0;

%o diffs.insert(thisdiff);

%o }

%o return 1;

%o }

%o int main(int argc, char *argv[])

%o {

%o for(int n=1; ; n++)

%o {

%o vector<int> s;

%o for(int i=1; i<=n; i++) s.push_back(i);

%o unsigned long long resul=0;

%o do { resul += k(s); }

%o while ( next_permutation(s.begin(), s.end()) );

%o cout << n << " " << resul << endl;

%o }

%o return 0;

%o }

%o /* _R. J. Mathar_, Oct 25 2007 */

%Y Cf. A040018, A091217, A006967.

%K more,nonn

%O 1,2

%A _Vladeta Jovovic_, Aug 26 2007

%E 2 more terms from _R. J. Mathar_, Oct 25 2007

%E 7 more terms from _R. H. Hardin_, Nov 26 2009

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 16 02:53 EDT 2024. Contains 371696 sequences. (Running on oeis4.)