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 A242527 #12 Oct 19 2018 16:58:53 %S A242527 0,0,0,0,1,1,2,6,6,22,80,504,840,6048,3888,37524,72976,961776,661016, %T A242527 11533030,7544366,133552142,208815294,5469236592,6429567323, %U A242527 153819905698,182409170334,4874589558919,7508950009102,209534365631599 %N A242527 Number of cyclic arrangements (up to direction) of {0,1,...,n-1} such that the sum of any two neighbors is a prime. %C A242527 a(n)=NPC(n;S;P) is the count of all neighbor-property cycles for a specific set S={0,1,...,n-1} of n elements and a specific pair-property P. For more details, see the link and A242519. %C A242527 For the same pair-property P but the set {1 through n}, see A051252. Using for pair-property the difference, rather than the sum, one obtains A228626. %H A242527 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 A242527 The first such cycle is of length n=5: {0,2,1,4,3}. %e A242527 The first case with 2 solutions is for cycle length n=7: %e A242527 C_1={0,2,3,4,1,6,5}, C_2={0,2,5,6,1,4,3}. %e A242527 The first and the last of the 22 such cycles of length n=10 are: %e A242527 C_1={0,3,2,1,4,9,8,5,6,7}, C_22={0,5,8,9,4,3,2,1,6,7}. %t A242527 A242527[n_] := Count[Map[lpf, Map[j0f, Permutations[Range[n - 1]]]], 0]/2; %t A242527 j0f[x_] := Join[{0}, x, {0}]; %t A242527 lpf[x_] := Length[Select[asf[x], ! PrimeQ[#] &]]; %t A242527 asf[x_] := Module[{i}, Table[x[[i]] + x[[i + 1]], {i, Length[x] - 1}]]; %t A242527 Table[A242527[n], {n, 1, 10}] %t A242527 (* OR, a less simple, but more efficient implementation. *) %t A242527 A242527[n_, perm_, remain_] := Module[{opt, lr, i, new}, %t A242527 If[remain == {}, %t A242527 If[PrimeQ[First[perm] + Last[perm]], ct++]; %t A242527 Return[ct], %t A242527 opt = remain; lr = Length[remain]; %t A242527 For[i = 1, i <= lr, i++, %t A242527 new = First[opt]; opt = Rest[opt]; %t A242527 If[! PrimeQ[Last[perm] + new], Continue[]]; %t A242527 A242527[n, Join[perm, {new}], %t A242527 Complement[Range[n - 1], perm, {new}]]; %t A242527 ]; %t A242527 Return[ct]; %t A242527 ]; %t A242527 ]; %t A242527 Table[ct = 0; A242527[n, {0}, Range[n - 1]]/2, {n, 1, 15}] %t A242527 (* _Robert Price_, Oct 18 2018 *) %o A242527 (C++) See the link. %Y A242527 Cf. A051252, A228626, A242519, A242520, A242521, A242522, A242523, A242524, A242525, A242526, A242528, A242529, A242530, A242531, A242532, A242533, A242534. %K A242527 nonn,hard %O A242527 1,7 %A A242527 _Stanislav Sykora_, May 30 2014 %E A242527 a(23)-a(30) from _Max Alekseyev_, Jul 09 2014