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.

Previous Showing 11-19 of 19 results.

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

Original entry on oeis.org

1, 1, 1, 1, 6, 2, 36, 36, 360, 288, 11016, 3888, 238464, 200448, 3176496, 4257792, 402573312, 139511808, 18240768000, 11813990400, 440506183680, 532754620416, 96429560832000, 32681097216000, 5244692024217600, 6107246661427200, 490508471914905600, 468867166554931200, 134183696369843404800
Offset: 1

Views

Author

Stanislav Sykora, May 30 2014

Keywords

Comments

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.

Examples

			There are 6 such cycles of length n=5: C_1={1,2,3,4,5}, C_2={1,2,3,5,4},
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}.
For length n=6, the count drops to just 2:
C_1={1,2,3,4,5,6}, C_2={1,4,3,2,5,6}.
		

Crossrefs

Programs

  • Mathematica
    A242529[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
    j1f[x_] := Join[{1}, x, {1}];
    lpf[x_] := Length[Select[cpf[x], # != 1 &]];
    cpf[x_] := Module[{i},
       Table[GCD[x[[i]], x[[i + 1]]], {i, Length[x] - 1}]];
    Join[{1, 1}, Table[A242529[n], {n, 3, 10}]]
    (* OR, a less simple, but more efficient implementation. *)
    A242529[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[GCD[First[perm], Last[perm]] == 1, ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[GCD[Last[perm], new] != 1, Continue[]];
          A242529[n, Join[perm, {new}],
           Complement[Range[2, n], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Join[{1, 1},Table[ct = 0; A242529[n, {1}, Range[2, n]]/2, {n, 3, 12}] ](* Robert Price, Oct 25 2018 *)

Formula

For n>2, a(n) = A086595(n)/2.

Extensions

a(1) corrected, a(19)-a(29) added by Max Alekseyev, Jul 04 2014

A242530 Number of cyclic arrangements of S={1,2,...,2n} such that the binary expansions of any two neighbors differ by one bit.

Original entry on oeis.org

0, 0, 1, 0, 2, 8, 0, 0, 224, 754, 0, 26256, 0, 0, 22472304, 0, 90654576, 277251016, 0, 7852128780
Offset: 1

Views

Author

Stanislav Sykora, May 30 2014

Keywords

Comments

Here, a(n)=NPC(2n;S;P) is the count of all neighbor-property cycles for a specific set S of 2n elements and a pair-property P. For more details, see the link and A242519.
In this case the property P is the Gray condition. The choice of the set S is important; when it is replaced by {0,1,2,...,2n-1}, the sequence changes completely and becomes A236602.

Examples

			The two cycles for n=5 (cycle length 10) are:
C_1={1,3,7,5,4,6,2,10,8,9}, C_2={1,5,4,6,7,3,2,10,8,9}.
		

Crossrefs

Programs

  • Mathematica
    A242530[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, 2 n]]]], 0]/2;
    j1f[x_] := Join[{1}, x, {1}];
    btf[x_] := Module[{i},
       Table[DigitCount[BitXor[x[[i]], x[[i + 1]]], 2, 1], {i,
         Length[x] - 1}]];
    lpf[x_] := Length[Select[btf[x], # != 1 &]];
    Table[A242530[n], {n, 1, 5}]
     (* OR, a less simple, but more efficient implementation. *)
    A242530[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[DigitCount[BitXor[First[perm], Last[perm]], 2, 1] == 1, ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[DigitCount[BitXor[Last[perm], new], 2, 1] != 1, Continue[]];
          A242530[n, Join[perm, {new}],
           Complement[Range[2, 2 n], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Table[ct = 0; A242530[n, {1}, Range[2, 2 n]]/2, {n, 1, 10}] (* Robert Price, Oct 25 2018 *)

Extensions

a(16)-a(20) from Fausto A. C. Cariboni, May 10 2017, May 15 2017

A242531 Number of cyclic arrangements of S={1,2,...,n} such that the difference of any two neighbors is a divisor of their sum.

Original entry on oeis.org

0, 1, 1, 1, 1, 4, 3, 9, 26, 82, 46, 397, 283, 1675, 9938, 19503, 10247, 97978, 70478, 529383, 3171795, 7642285, 3824927, 48091810, 116017829, 448707198, 1709474581, 6445720883, 3009267707, 51831264296
Offset: 1

Views

Author

Stanislav Sykora, May 30 2014

Keywords

Comments

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.

Examples

			The only such cycle of length n=5 is {1,2,4,5,3}.
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}.
		

Crossrefs

Programs

  • Mathematica
    A242531[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
    j1f[x_] := Join[{1}, x, {1}];
    dvf[x_] := Module[{i},
       Table[Divisible[x[[i]] + x[[i + 1]], x[[i]] - x[[i + 1]]], {i,
         Length[x] - 1}]];
    lpf[x_] := Length[Select[dvf[x], ! # &]];
    Join[{0, 1}, Table[A242531[n], {n, 3, 10}]]
    (* OR, a less simple, but more efficient implementation. *)
    A242531[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[Divisible[First[perm] + Last[perm],
           First[perm] - Last[perm]], ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[! Divisible[Last[perm] + new, Last[perm] - new], Continue[]];
          A242531[n, Join[perm, {new}],
           Complement[Range[2, n], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Join[{0, 1}, Table[ct = 0; A242531[n, {1}, Range[2, n]]/2, {n, 3, 13}]] (* Robert Price, Oct 25 2018 *)

Extensions

a(24)-a(28) from Fausto A. C. Cariboni, May 25 2017
a(29) from Fausto A. C. Cariboni, Jul 09 2020
a(30) from Fausto A. C. Cariboni, Jul 14 2020

A242532 Number of cyclic arrangements of S={2,3,...,n+1} such that the difference of any two neighbors is greater than 1, and a divisor of their sum.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 20, 39, 0, 0, 0, 0, 319, 967, 0, 0, 1464, 6114, 16856, 44370, 0, 0, 0, 0, 2032951, 8840796, 12791922, 101519154, 0, 0
Offset: 1

Views

Author

Stanislav Sykora, May 30 2014

Keywords

Comments

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.
For this property P and sets {0,1,2,...,n-1} or {1,2,...,n} the problem does not appear to have any solution.
a(40)=a(41)=a(42)=a(43)=a(46)=a(47)=0. - Fausto A. C. Cariboni, May 17 2017

Examples

			The shortest such cycle is of length n=9: {2,4,8,10,5,7,9,3,6}.
The next a(n)>0 occurs for n=14 and has 20 solutions.
The first and the last of these are:
C_1={2,4,8,10,5,7,14,12,15,13,11,9,3,6},
C_2={2,4,12,15,13,11,9,3,5,7,14,10,8,6}.
		

Crossrefs

Programs

  • Mathematica
    A242532[n_] := Count[Map[lpf, Map[j2f, Permutations[Range[3, n + 1]]]], 0]/2;
    j2f[x_] := Join[{2}, x, {2}];
    dvf[x_] := Module[{i},
       Table[Abs[x[[i]] - x[[i + 1]]] > 1 &&
         Divisible[x[[i]] + x[[i + 1]], x[[i]] - x[[i + 1]]], {i,
         Length[x] - 1}]];
    lpf[x_] := Length[Select[dvf[x], ! # &]];
    Table[A242532[n], {n, 1, 10}]
    (* OR, a less simple, but more efficient implementation. *)
    A242532[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[Abs[First[perm] - Last[perm]] > 1 &&
           Divisible[First[perm] + Last[perm], First[perm] - Last[perm]],
          ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[Abs[Last[perm] - new] <= 1 || !
             Divisible[Last[perm] + new, Last[perm] - new], Continue[]];
          A242532[n, Join[perm, {new}],
           Complement[Range[3, n + 1], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Table[ct = 0; A242532[n, {2}, Range[3, n + 1]]/2, {n, 1, 15}] (* Robert Price, Oct 25 2018 *)

Extensions

a(29)-a(37) from Fausto A. C. Cariboni, May 17 2017

A242533 Number of cyclic arrangements of S={1,2,...,2n} such that the difference of any two neighbors is coprime to their sum.

Original entry on oeis.org

1, 1, 2, 36, 288, 3888, 200448, 4257792, 139511808, 11813990400, 532754620416
Offset: 1

Views

Author

Stanislav Sykora, May 30 2014

Keywords

Comments

a(n)=NPC(2n;S;P) is the count of all neighbor-property cycles for a specific set S of 2n elements and a specific pair-property P. For more details, see the link and A242519.
Conjecture: in this case it seems that NPC(n;S;P)=0 for all odd n, so only the even ones are listed. This is definitely not the case when the property P is replaced by its negation (see A242534).

Examples

			For n=4, the only cycle is {1,2,3,4}.
The two solutions for n=6 are: C_1={1,2,3,4,5,6} and C_2={1,4,3,2,5,6}.
		

Crossrefs

Programs

  • Mathematica
    A242533[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, 2 n]]]], 0]/2;
    j1f[x_] := Join[{1}, x, {1}];
    lpf[x_] := Length[Select[cpf[x], ! # &]];
    cpf[x_] := Module[{i},
       Table[CoprimeQ[x[[i]] - x[[i + 1]], x[[i]] + x[[i + 1]]], {i,
         Length[x] - 1}]];
    Join[{1}, Table[A242533[n], {n, 2, 5}]]
    (* OR, a less simple, but more efficient implementation. *)
    A242533[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[CoprimeQ[First[perm] + Last[perm], First[perm] - Last[perm]],
          ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[! CoprimeQ[Last[perm] + new, Last[perm] - new], Continue[]];
          A242533[n, Join[perm, {new}],
           Complement[Range[2, 2 n], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Join[{1}, Table[ct = 0; A242533[n, {1}, Range[2, 2 n]]/2, {n, 2, 6}] ](* Robert Price, Oct 25 2018 *)

Extensions

a(10)-a(11) from Fausto A. C. Cariboni, May 31 2017, Jun 01 2017

A242534 Number of cyclic arrangements of S={1,2,...,n} such that the difference of any two neighbors is not coprime to their sum.

Original entry on oeis.org

1, 0, 0, 0, 0, 0, 0, 0, 0, 72, 288, 3600, 17856, 174528, 2540160, 14768640, 101030400, 1458266112, 11316188160, 140951577600, 2659218508800, 30255151463424, 287496736542720, 5064092578713600, 76356431941939200, 987682437203558400, 19323690313219522560
Offset: 1

Views

Author

Stanislav Sykora, May 30 2014

Keywords

Comments

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.
Compare this with A242533 where the property is inverted.

Examples

			The first and the last of the 72 cycles for n=10 are:
C_1={1,3,5,10,2,4,8,6,9,7} and C_72={1,7,5,10,8,4,2,6,3,9}.
There are no solutions for cycle lengths from 2 to 9.
		

Crossrefs

Programs

  • Mathematica
    A242534[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
    j1f[x_] := Join[{1}, x, {1}];
    lpf[x_] := Length[Select[cpf[x], ! # &]];
    cpf[x_] := Module[{i},
       Table[! CoprimeQ[x[[i]] - x[[i + 1]], x[[i]] + x[[i + 1]]], {i,
         Length[x] - 1}]];
    Join[{1}, Table[A242534[n], {n, 2, 10}]]
    (* OR, a less simple, but more efficient implementation. *)
    A242534[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[!
           CoprimeQ[First[perm] + Last[perm], First[perm] - Last[perm]],
          ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[CoprimeQ[Last[perm] + new, Last[perm] - new], Continue[]];
          A242534[n, Join[perm, {new}],
           Complement[Range[2, n], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Join[{1}, Table[ct = 0; A242534[n, {1}, Range[2, n]]/2, {n, 2, 12}] ](* Robert Price, Oct 25 2018 *)

Extensions

a(19)-a(27) from Hiroaki Yamanouchi, Aug 30 2014

A228626 Number of Hamiltonian cycles in the undirected simple graph G_n with vertices 1,...,n which has an edge connecting vertices i and j if and only if |i-j| is prime.

Original entry on oeis.org

0, 0, 0, 0, 1, 2, 4, 16, 60, 186, 433, 2215, 11788, 76539, 414240, 2202215, 9655287, 69748712, 444195809, 3703859949, 26688275292, 201673532931, 1265944917365, 11801735916539, 92511897525830, 753795624276096, 5237677221537738, 41074291450736424, 280906738160126067
Offset: 1

Views

Author

Zhi-Wei Sun, Aug 28 2013

Keywords

Comments

Conjecture: a(n) > 0 for all n > 4. In other words, for each n = 5,6,... there is a permutation i_1,...,i_n of 1,...,n such that |i_1-i_2|, |i_2-i_3|, ..., |i_{n-1}-i_n| and |i_n-i_1| are all prime.
Note that this conjecture is different from the prime circle problem in A051252 though they look similar.
On August 30 2013, Yong-Gao Chen (from Nanjing Normal University) confirmed the conjecture for n > 12 as follows: If n = 2*k then G_n contains a Hamiltonian cycle (1,3,5,2,7,9,...,2k-5,2k-3,2k,2k-2,2k-4,2k-1,2k-6,2k-8,...,6,4);
if n = 2*k + 1 then G_n contains a Hamiltonian cycle
(1,3,5,2,7,9,...,2k-5,2k,2k-3,2k-1,2k+1,2k-2,2k-4,...,6,4).
We have got Chen's approval to include his proof here.

Examples

			a(5) = 1 since G_5 contains the unique Hamiltonian cycle (1,4,2,5,3).
a(6) = 2 since G_6 contains exactly two Hamiltonian cycles: (1,3,5,2,4,6) and (1,4,2,5,3,6).
a(7) = 4 since G_7 contains exactly four Hamiltonian cycles: (1,3,5,2,7,4,6), (1,3,5,7,2,4,6), (1,4,2,7,5,3,6) and (1,4,7,2,5,3,6).
a(8) = 16 since G_8 contains exactly 16 Hamiltonian cycles: (1,3,5,2,7,4,6,8), (1,3,5,7,2,4,6,8), (1,3,6,4,2,7,5,8), (1,3,6,4,7,2,5,8), (1,3,6,8,5,2,7,4), (1,3,6,8,5,7,2,4), (1,3,8,5,2,7,4,6), (1,3,8,5,7,2,4,6), (1,4,2,7,5,3,6,8), (1,4,2,7,5,3,8,6), (1,4,2,7,5,8,3,6), (1,4,7,2,5,3,6,8), (1,4,7,2,5,3,8,6), (1,4,7,2,5,8,3,6), (1,6,4,2,7,5,3,8), (1,6,4,7,2,5,3,8).
a(9) > 0 since (1,3,5,7,9,2,4,6,8) is a Hamiltonian cycle in G_9.
a(10) > 0 since (1,3,5,2,4,6,9,7,10,8) is a Hamiltonian cycle in G_{10}.
a(11) > 0 since (1,3,5,10,8,11,9,2,7,4,6) is a Hamiltonian cycle in G_{11}.
a(12) > 0 since (1,3,8,10,5,2,7,4,6,11,9,12) is a Hamiltonian cycle in G_{12}.
		

Crossrefs

Programs

  • Mathematica
    Table[Length[FindHamiltonianCycle[Graph[Flatten[Table[If[PrimeQ[Abs[i - j]], i \[UndirectedEdge] j, {}], {i, 1, n}, {j, i + 1, n}]]], Infinity]], {n, 1, 15}] (* Robert Price, Apr 04 2019 *)

Extensions

a(9)-a(17) from Alois P. Heinz, Aug 28 2013
a(18)-a(19) from Stanislav Sykora, May 30 2014
a(20)-a(29) from Max Alekseyev, Jul 04 2014

A227050 Number of essentially different ways of arranging numbers 1 through 2n around a circle so that the sum and absolute difference of each pair of adjacent numbers are prime.

Original entry on oeis.org

0, 0, 0, 0, 0, 2, 1, 4, 88, 0, 976, 22277, 22365, 376002, 3172018, 5821944, 10222624, 424452210, 6129894510, 38164752224
Offset: 1

Views

Author

Tim Cieplowski, Jun 29 2013

Keywords

Comments

See a similar problem, but for the set of numbers {0 through (n-1)}. - Stanislav Sykora, May 30 2014

Examples

			For n = 6 the a(6) = 2 solutions are (1, 4, 9, 2, 5, 12, 7, 10, 3, 8, 11, 6) and (1, 6, 11, 8, 3, 10, 7, 4, 9, 2, 5, 12) because abs(1 - 4) = 3 and 1 + 4 = 5 are prime, etc.
		

Crossrefs

Cf. similar sequences: A051252 (with sums of neighbors prime), A242527 (with sums of neighbors prime), A228626 (with differences of neighbors prime), A242528 (with sums and differences of neighbors prime).

Programs

  • Mathematica
    A227050[n_] :=
    Count[Map[lpf, Map[j1f, Permutations[Range[2,2 n]]]], 0]/2;
    j1f[x_] := Join[{1}, x, {1}];
    lpf[x_] := Length[
       Join[Select[asf[x], ! PrimeQ[#] &],
        Select[Differences[x], ! PrimeQ[#] &]]];
    asf[x_] := Module[{i}, Table[x[[i]] + x[[i + 1]], {i, Length[x] - 1}]];
    Table[A227050[n], {n, 1, 6}]
    (* OR, a less simple, but more efficient implementation. *)
    A227050[n_, perm_, remain_] := Module[{opt, lr, i, new},
       If[remain == {},
         If[PrimeQ[First[perm] - Last[perm]] &&
           PrimeQ[First[perm] + Last[perm]], ct++];
         Return[ct],
         opt = remain; lr = Length[remain];
         For[i = 1, i <= lr, i++,
          new = First[opt]; opt = Rest[opt];
          If[! (PrimeQ[Last[perm] - new] && PrimeQ[Last[perm] + new]),
           Continue[]];
          A227050[n, Join[perm, {new}],
           Complement[Range[2 n], perm, {new}]];
          ];
         Return[ct];
         ];
       ];
    Table[ct = 0; A227050[n, {1}, Range[2, 2 n]]/2, {n, 1, 10}]
    (* Robert Price, Oct 22 2018 *)

Extensions

a(15)-a(18) added by Tim Cieplowski, Jan 04 2015
a(19) from Fausto A. C. Cariboni, Jun 06 2017
a(20) from Bert Dobbelaere, Feb 15 2020

A294184 a(n) is the number of ways to arrange numbers from 1 to 2*n in a row, starting with 1, such that the sum of every two adjacent numbers is prime, but also considering the ends as adjacent.

Original entry on oeis.org

1, 2, 2, 4, 96, 1024, 2880, 81024, 770144, 6309300, 213812336, 6395634044, 165849732426, 8050337724850, 255709623233382
Offset: 1

Views

Author

Michel Marcus, Feb 11 2018

Keywords

Comments

When the size of the row is odd, it is impossible to find such an arrangement, so that sequence is only defined for even-sized rows.

Examples

			a(1) = 1, because of [1, 2].
a(2) = 2, because of [1, 2, 3, 4] and [1, 4, 3, 2].
a(3) = 2, because of [1, 4, 3, 2, 5, 6] and [1, 6, 5, 2, 3, 4].
		

Crossrefs

Formula

a(n) = 2*A051252(n), for n > 1. - Giovanni Resta, Feb 25 2020

Extensions

a(9)-a(11) from Jackson Bahm, Feb 25 2020
a(12)-(15) from Giovanni Resta, using A051252, Feb 25 2020
Previous Showing 11-19 of 19 results.