login
a(n) is the least k>1 such that first n terms of Kolakoski sequence A000002 repeat beginning at k-th term.
5

%I #19 Mar 10 2020 17:52:31

%S 4,5,7,7,10,10,10,37,37,37,37,55,55,55,55,55,55,55,82,82,82,82,82,82,

%T 82,82,82,82,460,460,460,460,460,460,460,460,460,460,460,460,460,460,

%U 460,15585,15585,15585,15585,15585,15585,15585,15585,15585,15585,15585,15585

%N a(n) is the least k>1 such that first n terms of Kolakoski sequence A000002 repeat beginning at k-th term.

%H Rémy Sigrist, <a href="/A022294/b022294.txt">Table of n, a(n) for n = 1..10000</a>

%H Rémy Sigrist, <a href="/A022294/a022294.txt">C program for A022294</a>

%e 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.

%t n = 22; seq = Prepend[Nest[Flatten[Partition[#, 2] /. {{2, 2} -> {2, 2, 1, 1},

%t {2, 1} -> {2, 2, 1}, {1, 2} -> {2, 1, 1}, {1, 1} -> {2, 1}}] &,

%t {2, 2}, n], 1]; (* A000002 *)

%t seq = StringJoin[Map[ToString, seq]]; Most[Flatten[Rest[Reap[NestWhile[# + 1 &, 1,

%t Sow[First[Last[StringPosition[seq,

%t StringTake[seq, #], 2]]]] > 1 &]]]]] (* _Peter J. C. Moses_, Jan 05 2017 *)

%o (C) See Links section.

%Y Cf. A000002, A074300, A022295.

%K nonn

%O 1,1

%A _Clark Kimberling_