%I #19 Aug 26 2019 13:30:25
%S 0,0,1,2,1,1,2,1,3,5,1,4,2,2,3,1,5,1,6,7,1,7,1,8,4,1,9,3,2,4,2,5,2,6,
%T 1,10,9,1,11,3,3,4,3,5,3,6,2,7,2,8,1,12,13,1,13,1,14,4,4,5,4,6,3,7,3,
%U 8,2,9,2,10,1,15,15,1,16,3,9,3,10,2,11,1,17,8,3,11,2,12,1,18,7,4,7,5,5,6,4,8,4,9,4
%N If a(n) is not a term of a(0),...,a(n-1), then a(n+1) = n - m, where m is the most recent time that some new value a(m) appeared for the first time; otherwise a(n+1) is the number of terms equal to a(n) in a(0),...,a(n-1). Start with a(0)=0, a(1)=0.
%C 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).
%e a(0)=0 (given).
%e a(1)=0 (given).
%e 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.
%e 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.
%e 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.
%e 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.
%e 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.
%e 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.
%e 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.
%e 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.
%e 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.
%o (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
%Y Similar in spirit to A181391. - _N. J. A. Sloane_, Aug 26 2019
%K nonn
%O 0,4
%A _Marc Morgenegg_, Jul 08 2019
%E More terms from _Jinyuan Wang_, Aug 04 2019
|