OFFSET
1,3
LINKS
Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
Neal Gersh Tolunsky, Scatterplot of first 30000 terms
Neal Gersh Tolunsky, Scatterplot of first 100000 terms
EXAMPLE
For n=5, a(5) is the number of times a(5 - a(5-1)) = a(5 - a(4)) = a(3) = 2 has occurred in the sequence among a(1..3). It has occurred 1 time up to that point, so a(5)=1.
PROG
(Python)
from bisect import bisect
from itertools import count, islice
def agen(): # generator of terms
an, a, locs = 1, [None, 1], {1: [1]}
yield 1
for n in count(2):
k = n-an
an = bisect(locs[a[k]], k) # sum(1 for i in locs[a[k]] if i <= k)
a.append(an)
if an not in locs: locs[an] = []
locs[an].append(n)
yield an
print(list(islice(agen(), 86))) # Michael S. Branicky, May 23 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Neal Gersh Tolunsky, May 20 2023
STATUS
approved