A343887 a(1) = 1. Thereafter if a(n) is a novel term, a(n+1) = number of prior terms > a(n). If a(n) has been seen already, a(n+1) = a(n) + smallest prior term (which, once used, cannot be used again).
1, 0, 1, 1, 2, 0, 1, 1, 2, 3, 0, 1, 1, 2, 3, 5, 0, 2, 2, 4, 1, 3, 4, 6, 0, 3, 3, 6, 9, 0, 3, 3, 6, 9, 12, 0, 4, 4, 8, 3, 7, 4, 7, 11, 1, 5, 6, 11, 16, 0, 6, 6, 12, 18, 0, 6, 6, 12, 18, 24, 0, 6, 6, 12, 18, 25, 0, 7, 7, 14, 6, 13, 7, 13, 20, 2, 10, 16, 18, 27, 0
Offset: 1
Examples
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.
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.
Programs
-
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 *)
Comments