A022294 a(n) is the least k>1 such that first n terms of Kolakoski sequence A000002 repeat beginning at k-th term.
4, 5, 7, 7, 10, 10, 10, 37, 37, 37, 37, 55, 55, 55, 55, 55, 55, 55, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585, 15585
Offset: 1
Keywords
Examples
a(3) and a(4) are both 7 because A000002 begins 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, ... and 1, 2, 2 and 1, 2, 2, 1 both repeat at position 7.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
- Rémy Sigrist, C program for A022294
Programs
-
C
See Links section.
-
Mathematica
n = 22; seq = Prepend[Nest[Flatten[Partition[#, 2] /. {{2, 2} -> {2, 2, 1, 1}, {2, 1} -> {2, 2, 1}, {1, 2} -> {2, 1, 1}, {1, 1} -> {2, 1}}] &, {2, 2}, n], 1]; (* A000002 *) seq = StringJoin[Map[ToString, seq]]; Most[Flatten[Rest[Reap[NestWhile[# + 1 &, 1, Sow[First[Last[StringPosition[seq, StringTake[seq, #], 2]]]] > 1 &]]]]] (* Peter J. C. Moses, Jan 05 2017 *)