OFFSET
0,6
COMMENTS
After a(5) = 2 a record term produces a string of familiar terms leading to the next record, whereupon the process repeats (see Example). Since each record term increments its predecessor by +1, the records subsequence is A001477. If the first condition in Name is replaced by the "count back" function of A181391 the result is A025480 (n >= 1). The proper subsequence a(r), r a record = 0,1,2,3,..... is identical to the original, therefore the sequence contains infinitely many proper copies of itself. Every nonnegative integer appears infinitely many times.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^20, showing a(n) = 0 instead as a(n) = 1/2 for visibility.
Michael De Vlieger, Scalar plot of a(n), n = 1..2^18.
EXAMPLE
a(1) = 1 is a record term so a(2) = a(0) = 0 since 0 is the greatest record prior to 1. a(2) = 0, which has been seen once already so a(3) = 1, which has also been seen once already so a(4) = 1. Now there are two prior terms = 1, so a(5) = 2, and since this is a new record, a(6) = a(1) since 1 is the greatest record prior to 2. Therefore a(6) = 1. Now 1 has occurred 3 times prior to a(6) so a(7) = 3. The number of repeat terms between consecutive records varies, starting: 0,3,1,3,1,1..
MATHEMATICA
nn = 10000; c[_] := 0; z = a[0] = 0; c[0]++; r = a[1] = 1; q = True;
Do[If[q, k = a[z], k = c[a[n - 1]]];
c[a[n - 1]]++; Set[{a[n], q}, {k, False}];
If[k > r, Set[{z, r, q}, {r, k, True}] ], {n, 2, nn}];
Array[a, nn + 1, 0] (* Michael De Vlieger, May 14 2025 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
David James Sycamore, May 13 2025
STATUS
approved
