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.

A242529 Number of cyclic arrangements (up to direction) of numbers 1,2,...,n such that any two neighbors are coprime.

This page as a plain text file.
%I A242529 #20 Oct 25 2018 17:25:43
%S A242529 1,1,1,1,6,2,36,36,360,288,11016,3888,238464,200448,3176496,4257792,
%T A242529 402573312,139511808,18240768000,11813990400,440506183680,
%U A242529 532754620416,96429560832000,32681097216000,5244692024217600,6107246661427200,490508471914905600,468867166554931200,134183696369843404800
%N A242529 Number of cyclic arrangements (up to direction) of numbers 1,2,...,n such that any two neighbors are coprime.
%C A242529 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 of "being coprime". For more details, see the link and A242519.
%H A242529 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.
%H A242529 Wikipedia, <a href="http://en.wikipedia.org/wiki/Coprime_integers">Coprime integers</a>
%F A242529 For n>2, a(n) = A086595(n)/2.
%e A242529 There are 6 such cycles of length n=5: C_1={1,2,3,4,5}, C_2={1,2,3,5,4},
%e A242529 C_3={1,2,5,3,4}, C_4={1,2,5,4,3}, C_5={1,3,2,5,4}, and C_6={1,4,3,2,5}.
%e A242529 For length n=6, the count drops to just 2:
%e A242529 C_1={1,2,3,4,5,6}, C_2={1,4,3,2,5,6}.
%t A242529 A242529[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
%t A242529 j1f[x_] := Join[{1}, x, {1}];
%t A242529 lpf[x_] := Length[Select[cpf[x], # != 1 &]];
%t A242529 cpf[x_] := Module[{i},
%t A242529    Table[GCD[x[[i]], x[[i + 1]]], {i, Length[x] - 1}]];
%t A242529 Join[{1, 1}, Table[A242529[n], {n, 3, 10}]]
%t A242529 (* OR, a less simple, but more efficient implementation. *)
%t A242529 A242529[n_, perm_, remain_] := Module[{opt, lr, i, new},
%t A242529    If[remain == {},
%t A242529      If[GCD[First[perm], Last[perm]] == 1, ct++];
%t A242529      Return[ct],
%t A242529      opt = remain; lr = Length[remain];
%t A242529      For[i = 1, i <= lr, i++,
%t A242529       new = First[opt]; opt = Rest[opt];
%t A242529       If[GCD[Last[perm], new] != 1, Continue[]];
%t A242529       A242529[n, Join[perm, {new}],
%t A242529        Complement[Range[2, n], perm, {new}]];
%t A242529       ];
%t A242529      Return[ct];
%t A242529      ];
%t A242529    ];
%t A242529 Join[{1, 1},Table[ct = 0; A242529[n, {1}, Range[2, n]]/2, {n, 3, 12}] ](* _Robert Price_, Oct 25 2018 *)
%o A242529 (C++) See the link.
%Y A242529 Cf. A242519, A242520, A242521, A242522, A242523, A242524, A242525, A242526, A242527, A242528, A242530, A242531, A242532, A242533, A242534.
%K A242529 nonn,hard
%O A242529 1,5
%A A242529 _Stanislav Sykora_, May 30 2014
%E A242529 a(1) corrected, a(19)-a(29) added by _Max Alekseyev_, Jul 04 2014