OFFSET
1,2
COMMENTS
Pairs are numbered according to the position of the second term.
LINKS
Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
Eric Angelini, A seq with a strange behavior (or not)?
Neal Gersh Tolunsky, Scatterplot of first 100000 terms
EXAMPLE
a(1) = 1. The 1st constructed pair encloses 1 term: [1, 2, 1].
a(2) = 2. The 2nd constructed pair encloses 2 terms: [2, 1, 3, 2].
a(3) = 1. The 3rd constructed pair encloses 1 term: [3, 2, 3].
a(4) = 3. The 4th constructed pair encloses 3 terms: [1, 3, 2, 3, 1].
a(5) = 2. The 5th constructed pair encloses 2 terms: [2, 3, 1, 2].
a(6) = 3. The 6th constructed pair encloses 3 terms: [3, 1, 2, 4, 3].
a(7) = 1. The 7th constructed pair encloses 1 term: [4, 3, 4].
...
PROG
(Python)
from itertools import count, islice
def agen(): # generator of terms
a, indexes = [1], {1: 0}
yield a[-1]
for i in count(0):
num = 1
while True:
if num in indexes:
if (len(a) - indexes[num]) == (a[i]+1):
an = num; indexes[an] = len(a); a.append(an); yield an
break
else:
num += 1
else:
an = max(a)+1; indexes[an] = len(a); a.append(an); yield an
num = 1
print(list(islice(agen(), 100))) # Gavin Lupo and Michael S. Branicky, Jun 13 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and Gavin Lupo, Jun 13 2023
STATUS
approved