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.
%I A242531 #21 Jul 14 2020 20:30:17 %S A242531 0,1,1,1,1,4,3,9,26,82,46,397,283,1675,9938,19503,10247,97978,70478, %T A242531 529383,3171795,7642285,3824927,48091810,116017829,448707198, %U A242531 1709474581,6445720883,3009267707,51831264296 %N A242531 Number of cyclic arrangements of S={1,2,...,n} such that the difference of any two neighbors is a divisor of their sum. %C A242531 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 A242531 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. %e A242531 The only such cycle of length n=5 is {1,2,4,5,3}. %e A242531 For n=7 there are three solutions: C_1={1,2,4,5,7,6,3}, C_2={1,2,4,6,7,5,3}, C_3={1,2,6,7,5,4,3}. %t A242531 A242531[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2; %t A242531 j1f[x_] := Join[{1}, x, {1}]; %t A242531 dvf[x_] := Module[{i}, %t A242531 Table[Divisible[x[[i]] + x[[i + 1]], x[[i]] - x[[i + 1]]], {i, %t A242531 Length[x] - 1}]]; %t A242531 lpf[x_] := Length[Select[dvf[x], ! # &]]; %t A242531 Join[{0, 1}, Table[A242531[n], {n, 3, 10}]] %t A242531 (* OR, a less simple, but more efficient implementation. *) %t A242531 A242531[n_, perm_, remain_] := Module[{opt, lr, i, new}, %t A242531 If[remain == {}, %t A242531 If[Divisible[First[perm] + Last[perm], %t A242531 First[perm] - Last[perm]], ct++]; %t A242531 Return[ct], %t A242531 opt = remain; lr = Length[remain]; %t A242531 For[i = 1, i <= lr, i++, %t A242531 new = First[opt]; opt = Rest[opt]; %t A242531 If[! Divisible[Last[perm] + new, Last[perm] - new], Continue[]]; %t A242531 A242531[n, Join[perm, {new}], %t A242531 Complement[Range[2, n], perm, {new}]]; %t A242531 ]; %t A242531 Return[ct]; %t A242531 ]; %t A242531 ]; %t A242531 Join[{0, 1}, Table[ct = 0; A242531[n, {1}, Range[2, n]]/2, {n, 3, 13}]] (* _Robert Price_, Oct 25 2018 *) %o A242531 (C++) See the link. %Y A242531 Cf. A242519, A242520, A242521, A242522, A242523, A242524, A242525, A242526, A242527, A242528, A242529, A242530, A242532, A242533, A242534. %K A242531 nonn,hard,more %O A242531 1,6 %A A242531 _Stanislav Sykora_, May 30 2014 %E A242531 a(24)-a(28) from _Fausto A. C. Cariboni_, May 25 2017 %E A242531 a(29) from _Fausto A. C. Cariboni_, Jul 09 2020 %E A242531 a(30) from _Fausto A. C. Cariboni_, Jul 14 2020