OFFSET
1,4
COMMENTS
The curling number of a finite string S = (s(1),...,s(n)) is the largest integer k such that S can be written as xy^k for strings x and y (where y has positive length).
From Andrey Zabolotskiy, Mar 03 2017: (Start)
The sequence consists of 1's and 2's only.
If 2^k>=n-1, then a(n+2^k)>=a(n).
The density of 1's seems to converge to 1/6.
(End)
LINKS
Andrey Zabolotskiy, Table of n, a(n) for n = 1..16384
F. J. van de Bult, D. C. Gijswijt, J. P. Linderman, N. J. A. Sloane and Allan Wilks, A Slow-Growing Sequence Defined by an Unusual Recurrence, J. Integer Sequences, Vol. 10 (2007), #07.1.2.
MATHEMATICA
(* Function curlN is defined in A094840 *)
(* Function ThueMorse needs Mma version >= 11 *)
a[n_] := If[n == 1, 1, curlN[Array[ThueMorse, n-1, 0]]];
Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Oct 18 2024 *)
PROG
(Python)
p, tm, s = 8, 0, 1
for i in range(p):
tm += (tm^((1<<s)-1))<<s
s *= 2
print(1)
for i in range(1, 1<<p):
a = any(((tm>>(i-j))&((1<<j)-1)) == ((tm>>(i-2*j))&((1<<j)-1)) for j in range(1, i//2+1))
print(2 if a else 1)
# Andrey Zabolotskiy, Mar 03 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, May 26 2004
STATUS
approved