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 A242521 #26 Oct 24 2018 22:27:50 %S A242521 0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,9,42,231,1052,3818,10086,27892,90076, %T A242521 310301,993680,4663558,22038882,162588454,1246422151,8655752023, %U A242521 58951670318,347675502245 %N A242521 Number of cyclic arrangements (up to direction) of {1,2,...,n} such that the difference between any two neighbors is b^k for some b>1 and k>1. %C A242521 a(n)=NPC(n;S;P) is the count of all neighbor-property cycles for a specific set S={1,2,...,n} of n elements and a specific pair-property P. For more details, see the link and A242519. %H A242521 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 A242521 The two cycles of length n=13 (the smallest n such that a(n)>0) are: C_1={1,5,9,13,4,8,12,3,7,11,2,6,10}, C_2={1,9,5,13,4,8,12,3,7,11,2,6,10}. %t A242521 A242521[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2; %t A242521 j1f[x_] := Join[{1}, x, {1}]; %t A242521 lpf[x_] := Length[Select[Abs[Differences[x]], ! MemberQ[t, #] &]]; %t A242521 t = Flatten[Table[b^k, {k, 2, 5}, {b, 2, 5}]]; %t A242521 Table[A242521[n], {n, 1, 10}] %t A242521 (* OR, a less simple, but more efficient implementation. *) %t A242521 A242521[n_, perm_, remain_] := Module[{opt, lr, i, new}, %t A242521 If[remain == {}, %t A242521 If[MemberQ[t, Abs[First[perm] - Last[perm]]], ct++]; %t A242521 Return[ct], %t A242521 opt = remain; lr = Length[remain]; %t A242521 For[i = 1, i <= lr, i++, %t A242521 new = First[opt]; opt = Rest[opt]; %t A242521 If[! MemberQ[t, Abs[Last[perm] - new]], Continue[]]; %t A242521 A242521[n, Join[perm, {new}], %t A242521 Complement[Range[2, n], perm, {new}]]; %t A242521 ]; %t A242521 Return[ct]; %t A242521 ]; %t A242521 ]; %t A242521 t = Flatten[Table[b^k, {k, 2, 5}, {b, 2, 5}]]; %t A242521 Table[ct = 0; A242521[n, {1}, Range[2, n]]/2, {n, 1, 18}] (* _Robert Price_, Oct 24 2018 *) %o A242521 (C++) See the link. %Y A242521 Cf. A242519, A242520, A242522, A242523, A242524, A242525, A242526, A242527, A242528, A242529, A242530, A242531, A242532, A242533, A242534. %K A242521 nonn,hard,more %O A242521 1,13 %A A242521 _Stanislav Sykora_, May 27 2014 %E A242521 a(27)-a(30) from _Max Alekseyev_, Jul 12 2014 %E A242521 a(31)-a(32) from _Fausto A. C. Cariboni_, May 17 2017, May 24 2017