A353778 a(1)=1. If a(n) is a novel term (seen for first time), a(n+1) = number of prior terms a(j) > a(n), 1 <= j <= n-1. If a(n) is a repeat of a term last seen at a(m), m < n, then a(n+1) = n-m-1.
1, 0, 1, 1, 0, 2, 0, 1, 3, 0, 2, 4, 0, 2, 2, 0, 2, 1, 9, 0, 3, 11, 0, 2, 6, 2, 1, 8, 2, 2, 0, 7, 3, 11, 11, 0, 4, 24, 0, 2, 9, 21, 1, 15, 2, 4, 8, 18, 2, 3, 16, 3, 1, 9, 12, 5, 16, 5, 1, 5, 1, 1, 0, 23, 1, 2, 16, 9, 13, 8, 22, 2, 5, 12, 18, 26, 0, 13, 8, 8, 0
Offset: 1
Keywords
Examples
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.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A328096.
Programs
-
Mathematica
Block[{a, c, k, m, s, nn}, 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 *)
Comments