OFFSET
1,6
COMMENTS
a(n) <= n for all n, with equality when n=1. Similar to A328096 initially, because novel terms are all records to begin with, but diverges when non-record novel terms appear, which produce nonzero following terms.
EXAMPLE
a(1)=1 is a novel record term, hence a(2)=0. a(3)=1 because a(2)=0 is a novel (non-record) term and only one term, a(1), exceeds it.
a(25) is the first occurrence of 6, so a(26)=2 because two prior terms (9 and 11) are greater than 6.
a(37) is the second occurrence of 4, first seen at a(12), therefore a(38)=37-12-1=24.
MATHEMATICA
nn = 81; c[_] = -1; a[1] = c[1] = 1; s = {}; Do[m = LengthWhile[s, # > a[i - 1] &]; Set[k, If[c[#] == -1, m, i - c[#] - 1]] &@ a[i - 1]; Set[{a[i], c[a[i - 1]]}, {k, i}]; s = Insert[s, a[i - 1], 1 + m], {i, 2, nn}]; Array[a, nn] (* Michael De Vlieger, May 08 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
David James Sycamore, May 07 2022
STATUS
approved