%I #46 Jan 26 2023 15:29:23
%S 2,2,2,3,2,2,2,3,2,2,2,3,3,2,2,2,3,2,2,2,3,2,2,2,3,3,2,2,2,3,2,2,2,3,
%T 2,2,2,3,3,3,3,4,2,2,2,3,2,2,2,3,2,2,2,3,3,2,2,2,3,2,2,2,3,2,2,2,3,3,
%U 2,2,2,3,2,2,2,3,2,2,2,3,3,3,3,4,2,2,2,3,2,2,2,3,2,2,2,3,3,2,2
%N a(1) = 2. To get a(n+1), write the string a(1)a(2)...a(n) as xy^k for words x and y (where y has positive length) and k is maximized, i.e., k = the maximal number of repeating blocks at the end of the sequence so far. Then a(n+1) = max(k,2).
%C Here xy^k means the concatenation of the words x and k copies of y.
%C a(77709404388415370160829246932345692180) = 5 is the first time 5 appears.
%C This is also the concatenation of the glue strings of A090822, whose respective lengths are given in A091579. - _M. F. Hasler_, Oct 04 2018
%C This sequence is called the level-2 Gijswijt sequence.
%D N. J. A. Sloane, Seven Staggering Sequences, in Homage to a Pied Puzzler, E. Pegg Jr., A. H. Schoen and T. Rodgers (editors), A. K. Peters, Wellesley, MA, 2009, pp. 93-110.
%H Giovanni Resta, <a href="/A091787/b091787.txt">Table of n, a(n) for n = 1..10000</a>
%H F. J. van de Bult, D. C. Gijswijt, J. P. Linderman, N. J. A. Sloane and Allan Wilks, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL10/Sloane/sloane55.html">A Slow-Growing Sequence Defined by an Unusual Recurrence</a>, J. Integer Sequences, Vol. 10 (2007), #07.1.2.
%H B. Chaffin, J. P. Linderman, N. J. A. Sloane and Allan Wilks, <a href="http://arxiv.org/abs/1212.6102">On Curling Numbers of Integer Sequences</a>, arXiv:1212.6102 [math.CO], Dec 25 2012.
%H B. Chaffin, J. P. Linderman, N. J. A. Sloane and Allan Wilks, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL16/Sloane/sloane3.html">On Curling Numbers of Integer Sequences</a>, Journal of Integer Sequences, Vol. 16 (2013), Article 13.4.3.
%H N. J. A. Sloane, <a href="http://neilsloane.com/doc/g4g7.pdf">Seven Staggering Sequences</a>.
%H <a href="/index/Ge#Gijswijt">Index entries for sequences related to Gijswijt's sequence</a>
%H Levi van de Pol, <a href="https://arxiv.org/abs/2209.04657">The first occurrence of a number in Gijswijt's sequence</a>, arXiv:2209.04657 [math.CO], 2022.
%e To get a(2): a(1) = 2 = (2)^1, so k = 1, a(2) = 2.
%e To get a(3): a(1)a(2) = 22 = (2)^2, so a(3) = k = 2.
%e To get a(4): a(1)a(2)a(3) = 222 = (2)^3, so a(3) = k = 3.
%o (PARI) A091787(n, A=[])={while(#A<n, my(k=2, L=0, m=k); while((k+1)*(L+1)<=#A, for(N=L+1, #A/(m+1), A[-m*N..-1]==A[-(m+1)*N..-N-1]&&(m+=1)&&break); m>k||break; k=m); A=concat(A, k)); A} \\ _M. F. Hasler_, Oct 04 2018
%o (Python)
%o from itertools import islice
%o def c(w):
%o for k in range(len(w), 0, -1):
%o for l in range(1, len(w)//k + 1):
%o if w[-k*l:] == w[-l:]*k: return k
%o def agen(): # generator of terms
%o alst, an = [], 2
%o while True: yield an; alst.append(an); an = max(2, c(alst))
%o print(list(islice(agen(), 99))) # _Michael S. Branicky_, Sep 10 2022
%Y Cf. A090822, A091799, A091840.
%K nonn
%O 1,1
%A _N. J. A. Sloane_, Mar 07 2004