OFFSET
0,4
COMMENTS
In other words, if the last term a(n) has not appeared previously, take the difference between its index n and the lowest index m of the last term to appear for the first time to obtain the next term. Otherwise, the next term is the number of terms equal to a(n) in a(0),...,a(n-1).
EXAMPLE
a(0)=0 (given).
a(1)=0 (given).
a(2)=1: a(1)=0 is a term of a(0..0), therefore a(2) = number of terms=0 in a(0..0) = 1.
a(3)=2: a(2)=1 is not a term of a(0..1), first appearance of a new term is at a(0), therefore a(3) = 2 - 0 = 2.
a(4)=1: a(3)=2 is not a term of a(0..2), first appearance of a new term is at a(2), therefore: 3 - 2 = 1.
a(5)=1: a(4)=1 is a term of a(0..3), therefore a(5) = Number of terms=1 in a(0..3) = 1.
a(6)=2: a(5)=1 is a term of a(0..4), therefore a(6) = Number of terms=1 in a(0..4) = 2.
a(7)=1: a(6)=2 is a term of a(0..5), therefore a(7) = Number of terms=2 in a(0..5) = 1.
a(8)=3: a(7)=1 is a term of a(0..6), therefore a(8) = Number of terms=1 in a(0..6) = 3.
a(9)=5: a(8)=3 is not a term of a(0..7), first appearance of a new term is at a(3), therefore: 8 - 3 = 5.
a(10)=1: a(9)=5 is not a term of a(0..8), first appearance of a new term is at a(8), therefore: 9 - 8 = 1.
PROG
(PARI) lista(NN) = {v = vector(NN); m=0; v[1]=0; v[2]=1; for(k=2, NN-1, v[k+1]=sum(j=1, k-1, v[j]==v[k]); if(v[k+1]==0, v[k+1]=k-m; m=k)); print1(0); for(i=1, NN, print1(", ", v[i])); } \\ Jinyuan Wang, Aug 04 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Marc Morgenegg, Jul 08 2019
EXTENSIONS
More terms from Jinyuan Wang, Aug 04 2019
STATUS
approved