cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A174707 The number of permutations p of {1,...,n} such that |p(i)-p(i+1)| is in {3,4,5} for all i from 1 to n-1.

This page as a plain text file.
%I A174707 #40 Dec 23 2024 14:53:42
%S A174707 1,0,0,0,0,2,28,144,292,272,160,272,844,3888,15830,49080,113468,
%T A174707 208224,352112,662810,1497286,3853054,10238142,25892602,60223752,
%U A174707 130042700,271136524,572265830,1258121046,2878870324,6714840216,15583281118,35434903508,78777769972,172664047056
%N A174707 The number of permutations p of {1,...,n} such that |p(i)-p(i+1)| is in {3,4,5} for all i from 1 to n-1.
%C A174707 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 {3,4,5}.
%H A174707 Andrew Howroyd, <a href="/A174707/b174707.txt">Table of n, a(n) for n = 1..100</a>
%H A174707 W. Edwin Clark, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2010-March/004193.html">permutations p in S_n such that m <= |p(i)-p(i+1)| <= M for i from 1 to n-1</a>, SeqFan Discussion, Mar 2010.
%e A174707 For n = 6 the a(6) = 2 permutations are (3,6,2,5,1,4), (4,1,5,2,6,3).
%p A174707 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(3, 5, n); seq(a(n), n=1..14); # _Alois P. Heinz_, Mar 27 2010
%t A174707 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[3, 5, n]; Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 1, 14}] (* _Jean-François Alcover_, Jun 01 2015, after _Alois P. Heinz_ *)
%Y A174707 Cf. A003274, A174700, A174701, A174702, A174703, A174704, A174705, A174706, A174708, A185030, A216837.
%K A174707 nonn
%O A174707 1,6
%A A174707 _W. Edwin Clark_, Mar 27 2010
%E A174707 Edited by _Alois P. Heinz_, Nov 27 2010
%E A174707 a(26)-a(35) from _Andrew Howroyd_, Apr 05 2016