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!)
A174702 The number of permutations p of {1,...,n} such that |p(i)-p(i+1)| is in {1,2,3,4,5} for all i from 1 to n-1. 13
1, 2, 6, 24, 120, 720, 3600, 15600, 61872, 236388, 901748, 3509106, 13716168, 53327912, 205176192, 780194112, 2937412512, 10991746368, 40961976672, 152144989056, 563313879080, 2078732476328, 7644789439842, 28024241472936, 102432262746504 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
For n>1, a(n)/2 is the number of Hamiltonian paths on the graph with vertex set {1,...,n} where i is adjacent to j iff |i-j| is in {1,2,3,4,5}.
LINKS
MAPLE
f:= proc(m, M, n) option remember; local i, l, p, cnt; l:= array([i$i=1..n]); cnt:=0; p:= proc(t) local d, j, h; if t=n then d:= `if`(t=1, m, abs(l[t]-l[t-1])); if m<=d and d<=M then cnt:= cnt+1 fi else for j from t to n do l[t], l[j]:= l[j], l[t]; d:= `if`(t=1, m, abs(l[t]-l[t-1])); if m<=d and d<=M then p(t+1) fi od; h:= l[t]; for j from t to n-1 do l[j]:= l[j+1] od; l[n]:= h fi end; p(1); cnt end: a:= n-> f(1, 5, n): seq(a(n), n=1..10); # Alois P. Heinz, Mar 27 2010
MATHEMATICA
f[m_, M_, n_] := f[m, M, n] = Module[{i, l, p, cnt}, Do[l[i] = i, {i, 1, n}]; cnt = 0; p[t_] := Module[{d, j, h}, If[t == n, d = If[t == 1, m, Abs[l[t] - l[t-1]]]; If [m <= d && d <= M, cnt = cnt+1], For[j = t, j <= n, j++, {l[t], l[j]} = {l[j], l[t]}; d = If[t == 1, m, Abs[l[t] - l[t-1]]]; If [m <= d && d <= M, p[t+1]]]; h = l[t]; For[j = t, j <= n-1, j++, l[j] = l[j+1]]; l[n] = h]]; p[1]; cnt]; a[n_] := f[1, 5, n]; Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 1, 10}] (* slow beyond n = 10 *) (* Jean-François Alcover, Jun 01 2015, after Alois P. Heinz *)
CROSSREFS
Sequence in context: A189857 A189860 A274795 * A173846 A154654 A189862
KEYWORD
nonn
AUTHOR
W. Edwin Clark, Mar 27 2010
EXTENSIONS
a(15)-a(20) from R. H. Hardin, May 06 2010
a(21)-a(25) from Andrew Howroyd, Apr 05 2016
STATUS
approved

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 March 28 16:58 EDT 2024. Contains 371254 sequences. (Running on oeis4.)