OFFSET
1,3
COMMENTS
The word 'set' means that every element is unique. For example, the set {1,1,2} contains 2 elements (not 3).
Note that we are considering sets between every pair of equal values, not just those that appear consecutively.
Two consecutive values enclose 0 terms, and thus after [a(1), a(2)] = [1, 1], no consecutive equal values occur again.
LINKS
Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
Rémy Sigrist, PARI program
EXAMPLE
a(1)=1; no pair of terms exists yet.
a(2)=1 creates the pair [1, 1], which encloses 0 elements. This means that no consecutive equal values can occur again, since this would create another set of 0 elements.
a(3)=2 because if a(3)=1, this would create a second pair enclosing 0 elements.
a(4)=1 creates two new sets: [1, 2, 1], enclosing 1 element {2}, and [1, 1, 2, 1], enclosing 2 elements {1, 2}.
a(5) cannot be 1 as this would again create a pair enclosing 0 elements [1,1]. 2 would create the pair [2, 1, 2] which encloses 1 element {1}, which has been impossible since a(4). So a(5)=3, which has not occurred before.
PROG
(PARI) See Links section.
(Python)
from itertools import islice
def agen(): # generator of terms
e, a = set(), []
while True:
an, allnew = 0, False
while not allnew:
allnew, an, ndset = True, an+1, set()
for i in range(len(a)):
if an == a[i]:
nd = len(set(a[i+1:]))
if nd in e or nd in ndset: allnew = False; break
ndset.add(nd)
yield an; a.append(an); e |= ndset
print(list(islice(agen(), 72))) # Michael S. Branicky, Oct 25 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Neal Gersh Tolunsky, Oct 17 2023
EXTENSIONS
More terms from Rémy Sigrist, Oct 25 2023
STATUS
approved