login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 16
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 9, 42, 231, 1052, 3818, 10086, 27892, 90076, 310301, 993680, 4663558, 22038882, 162588454, 1246422151, 8655752023, 58951670318, 347675502245 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,13
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. For more details, see the link and A242519.
LINKS
S. Sykora, On Neighbor-Property Cycles, Stan's Library, Volume V, 2014.
EXAMPLE
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}.
MATHEMATICA
A242521[n_] := Count[Map[lpf, Map[j1f, Permutations[Range[2, n]]]], 0]/2;
j1f[x_] := Join[{1}, x, {1}];
lpf[x_] := Length[Select[Abs[Differences[x]], ! MemberQ[t, #] &]];
t = Flatten[Table[b^k, {k, 2, 5}, {b, 2, 5}]];
Table[A242521[n], {n, 1, 10}]
(* OR, a less simple, but more efficient implementation. *)
A242521[n_, perm_, remain_] := Module[{opt, lr, i, new},
If[remain == {},
If[MemberQ[t, Abs[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[! MemberQ[t, Abs[Last[perm] - new]], Continue[]];
A242521[n, Join[perm, {new}],
Complement[Range[2, n], perm, {new}]];
];
Return[ct];
];
];
t = Flatten[Table[b^k, {k, 2, 5}, {b, 2, 5}]];
Table[ct = 0; A242521[n, {1}, Range[2, n]]/2, {n, 1, 18}] (* Robert Price, Oct 24 2018 *)
PROG
(C++) See the link.
CROSSREFS
Sequence in context: A271927 A227526 A093081 * A338298 A366581 A073659
KEYWORD
nonn,hard,more
AUTHOR
Stanislav Sykora, May 27 2014
EXTENSIONS
a(27)-a(30) from Max Alekseyev, Jul 12 2014
a(31)-a(32) from Fausto A. C. Cariboni, May 17 2017, May 24 2017
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 14:38 EDT 2024. Contains 371254 sequences. (Running on oeis4.)