Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A131529
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A131529 Number of permutations of {1,2,...n} for which differences of adjacent numbers are all distinct. +0
1
1, 2, 4, 12, 44, 176, 788, 3936, 23264, 152112, 1104876, 8725320 (list; graph; listen)
OFFSET

1,2

PROGRAM

(C++) #include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; inline int k(const vector<int> & s) { const int n = s.size() ; set<int> diffs ; for(int i=1; i<n; i++) { const int thisdiff = s[i]-s[i-1] ; if ( diffs.find(thisdiff) != diffs.end() ) return 0 ; else diffs.insert(thisdiff) ; } return 1 ; } 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 += k(s) ; } while( next_permutation(s.begin(), s.end()) ) ; cout << n << " " << resul << endl ; } return 0 ; } - R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Oct 25 2007

CROSSREFS

Cf. A040018, A091217, A006967.

Sequence in context: A096802 A139669 A039301 this_sequence A074449 A131387 A004527

Adjacent sequences: A131526 A131527 A131528 this_sequence A131530 A131531 A131532

KEYWORD

more,nonn

AUTHOR

Vladeta Jovovic (vladeta(AT)Eunet.yu), Aug 26 2007

EXTENSIONS

2 more terms from R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Oct 25 2007

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified July 26 23:19 EDT 2008. Contains 142293 sequences.


AT&T Labs Research