OFFSET
1,5
COMMENTS
The sequence is nontrivial if and only if a(1) > 0. a(n) <= n for n <= 10000, but it is not known if this holds for all n. a(n) + a(n+1) <= n is usually but not always true (first exception is at n=509; a(509) + a(510) = 248 + 311 = 559).
For n > 1, a(n) = 0 if and only if a(n-1) is a record novel term, whereas every non-record novel term is followed by a nonzero term. Let S(n) be the set of unused terms prior to a(n), then step function |S(n)| increments +1 at a(k+1), where a(k) is a novel term. S(n) typically contains multiple copies of each unused number, providing a continuously incremented supply of least prior terms to add to repeat leading terms as the sequence extends. This suggests that there is always a next record, and hence that zero occurs infinitely many times. Indices of records: 1, 5, 10, 16, 24, 29, 35, 49, 54, 60, 66, 80, 86, 114, 136, 166, 176, 192, 198, 231, ...
If a(k) is a record term, we see a(k), 0, m, m, ... where m is the least member of S(k). Between any consecutive pair of zeros we see either no novel terms, in which case the trajectory climbs quickly to the next record term, or there are novel terms, each of which disturbs and extends the trajectory to the next record (see plots).
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..10000
Michael De Vlieger, Scatterplot of a(n) for n = 1..2^18.
Michael De Vlieger, Labeled scatterplot of a(n) for n = 1..2^9 showing records in red, zeros in blue, repeated terms in black, terms instigated by a new previous term in gold, and green otherwise.
EXAMPLE
a(2)=0 since a(1)=1 is a novel term and there are zero terms prior to a(1) which are greater than 1. a(3)=1 since a(2)=0 is a novel term and there is one prior term (a(1)=1) which is > 0. a(4)=1+0=1 because a(3) is a repeat term and the smallest unused prior term is 0.
MATHEMATICA
Block[{a = {1}, s = {}}, Do[If[FreeQ[#2, #1], AppendTo[a, Count[#2, _?(# > a[[-1]] &)] ], AppendTo[a, a[[-1]] + First[s] ]; Set[s, Rest@ s]] & @@ {First[#1], #2} & @@ TakeDrop[a, -1]; Set[s, Insert[s, a[[-2]], LengthWhile[s, # < a[[-2]] &] + 1]], 80]; a] (* Michael De Vlieger, May 03 2021 *)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
David James Sycamore, May 02 2021
STATUS
approved