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.

A242526 Number of cyclic arrangements of S={1,2,...,n} such that the difference between any two neighbors is at most 4.

This page as a plain text file.
%I A242526 #25 Oct 25 2018 17:25:36
%S A242526 1,1,1,3,12,36,90,214,521,1335,3473,9016,23220,59428,152052,389636,
%T A242526 999776,2566517,6586825,16899574,43352560,111213798,285319258,
%U A242526 732016006,1878072638,4818362046,12361809384,31714901077,81366445061,208750870961
%N A242526 Number of cyclic arrangements of S={1,2,...,n} such that the difference between any two neighbors is at most 4.
%C A242526 a(n)=NPC(n;S;P) is the count of all neighbor-property cycles for a specific set S of n elements and a specific pair-property P. For more details, see the link and A242519.
%H A242526 Andrew Howroyd, <a href="/A242526/b242526.txt">Table of n, a(n) for n = 1..100</a>
%H A242526 S. Sykora, <a href="http://dx.doi.org/10.3247/SL5Math14.002">On Neighbor-Property Cycles</a>, <a href="http://ebyte.it/library/Library.html#math">Stan's Library</a>, Volume V, 2014.
%F A242526 From _Andrew Howroyd_, Apr 08 2016: (Start)
%F A242526 Empirical: a(n) = 2*a(n-1) + a(n-2) - a(n-4) + 9*a(n-5) + 5*a(n-6) - a(n-7) - 7*a(n-8) - 10*a(n-9) + 2*a(n-10) + 2*a(n-11) + 2*a(n-12) + 4*a(n-13) - 2*a(n-17) - a(n-18) for n>20.
%F A242526 Empirical g.f.: x + (3 - 6*x - 2*x^2 - x^3 + 3*x^4 - 22*x^5 - 5*x^6 + x^7 + 8*x^8 + 14*x^9 - 6*x^10 + 2*x^11 - 6*x^12 - 6*x^13 - 3*x^15 + x^16 + 3*x^17) / (1 - 2*x - x^2 + x^4 - 9*x^5 - 5*x^6 + x^7 + 7*x^8 + 10*x^9 - 2*x^10 - 2*x^11 - 2*x^12 - 4*x^13 + 2*x^17 + x^18). (End)
%e A242526 The 3 cycles of length n=4 are: {1,2,3,4},{1,2,4,3},{1,3,2,4}.
%e A242526 The first and the last of the 1335 such cycles of length n=10 are:
%e A242526 C_1={1,2,3,4,6,7,8,10,9,5}, C_1335={1,4,8,10,9,7,6,3,2,5}.
%t A242526 A242526[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
%t A242526 j1f[x_] := Join[{1}, x, {1}];
%t A242526 lpf[x_] := Length[Select[Abs[Differences[x]], # > 4 &]];
%t A242526 Join[{1, 1}, Table[A242526[n], {n, 3, 10}]]
%t A242526 (* OR, a less simple, but more efficient implementation. *)
%t A242526 A242526[n_, perm_, remain_] := Module[{opt, lr, i, new},
%t A242526    If[remain == {},
%t A242526      If[Abs[First[perm] - Last[perm]] <= 4, ct++];
%t A242526      Return[ct],
%t A242526      opt = remain; lr = Length[remain];
%t A242526      For[i = 1, i <= lr, i++,
%t A242526       new = First[opt]; opt = Rest[opt];
%t A242526       If[Abs[Last[perm] - new] > 4, Continue[]];
%t A242526       A242526[n, Join[perm, {new}],
%t A242526        Complement[Range[2, n], perm, {new}]];
%t A242526       ];
%t A242526      Return[ct];
%t A242526      ];
%t A242526    ];
%t A242526 Join[{1, 1}, Table[ct = 0; A242526[n, {1}, Range[2, n]]/2, {n, 3, 12}] ](* _Robert Price_, Oct 25 2018 *)
%o A242526 (C++) See the link.
%Y A242526 Cf. A242519, A242520, A242521, A242522, A242523, A242524, A242525, A242527, A242528, A242529, A242530, A242531, A242532, A242533, A242534.
%K A242526 nonn
%O A242526 1,4
%A A242526 _Stanislav Sykora_, May 27 2014
%E A242526 a(22)-a(30) from _Andrew Howroyd_, Apr 08 2016