login
a(0) = 0; a(1) = 1; for n > 1, a(n) = number of terms between the two previous occurrences of a(n-1) if a(n-1) has appeared two or more times, otherwise a(n) = 0.
3

%I #17 Oct 05 2019 04:05:27

%S 0,1,0,1,1,0,2,0,1,3,0,2,4,0,2,2,0,2,1,9,0,3,11,0,2,6,0,2,2,0,2,1,12,

%T 0,3,12,2,5,0,4,26,0,2,5,5,0,3,11,24,0,3,3,0,2,10,0,2,2,0,2,1,28,0,3,

%U 11,16,0,3,3,0,2,10,16,6,47,0,5,31,0,2,8

%N a(0) = 0; a(1) = 1; for n > 1, a(n) = number of terms between the two previous occurrences of a(n-1) if a(n-1) has appeared two or more times, otherwise a(n) = 0.

%C In the first 10000 terms the largest entry is 9040, which is the number of terms between the two appearances of 217. The longest run of nonzero values is 19, starting at a(9740) = 3 and ending at a(9758) = 6400. The smallest number not appearing is 258.

%H Scott R. Shannon, <a href="/A328096/b328096.txt">Table of n, a(n) for n = 0..10000</a>

%e a(3) = 1 as there is 1 term between a(3-1) = a(2) = 0 and a(0) = 0.

%e a(5) = 0 as there are no terms between a(5-1) = a(4) = 1 and a(3) = 1.

%e a(7) = 0 as a(7-1) = a(6) = 2 has only appeared once up to n = 7.

%e a(12) = 4 as there are 4 terms between a(12-1) = a(11) = 2 and a(6) = 2.

%e a(22) = 11 as there are 11 terms between a(22-1) = a(21) = 3 and a(9) = 3.

%p a:= proc(n) option remember; local t, j;

%p if n<2 then n else t:= a(n-1);

%p for j from 2 to n do

%p if a(n-j)=t then return j-2 fi

%p od; 0

%p fi

%p end:

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Oct 04 2019

%t a = {0,1}; While[Length@a < 90, p = Flatten@ Position[Reverse@ a, Last@a, 1, 2]; AppendTo[a, If[ Length@p == 1, 0, p[[2]] - p[[1]] - 1]]]; a (* _Giovanni Resta_, Oct 04 2019 *)

%Y Cf. A181391, A309261.

%K nonn

%O 0,7

%A _Scott R. Shannon_, Oct 04 2019