|
|
A363193
|
|
a(1)=1, and thereafter a(n) = number of occurrences of a(k) among terms a(1..k), where k = n-a(n-1).
|
|
3
|
|
|
1, 1, 2, 2, 1, 3, 2, 1, 4, 1, 5, 3, 5, 1, 6, 5, 2, 3, 3, 4, 4, 3, 2, 5, 2, 4, 5, 5, 4, 4, 5, 5, 6, 6, 5, 7, 6, 8, 7, 2, 2, 7, 1, 7, 1, 8, 2, 2, 9, 8, 7, 8, 8, 2, 5, 5, 4, 11, 10, 3, 1, 9, 11, 5, 6, 6, 9, 1, 10, 6, 5, 3, 7, 3, 7, 2, 7, 13, 6, 8, 6, 12, 13, 13, 7, 8
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
LINKS
|
|
|
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|