OFFSET
1,3
COMMENTS
The phrases are formed by the Ziv-Lempel encoding described in A106182. - Neal Gersh Tolunsky, Nov 30 2023
LINKS
Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
EXAMPLE
Consider the infinite sequence [1,2,1,3,2,1,4,3,2,1,5,4,3,2,1,...], i.e., A004736. We can first take [1] since we've never used it before. Then [2]. For the third term, we've already used [1], so we must instead take [1,3].
PROG
(Python)
# you should use program from internal format
a = set()
i = 2
s = "1"
seq = ""
while i < 100:
j = i
while j > 0:
if s not in a:
seq = seq + ", " + str(len(s)-len(s.replace(", ", ""))+1)
a.add(s)
s = str(j)
else:
s = s + ", " + str(j)
j -= 1
i += 1
print(seq[1:])
CROSSREFS
KEYWORD
nonn
AUTHOR
Lewis Chen, Jun 11 2017
STATUS
approved