login
A328096
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
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, 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, 11, 16, 0, 3, 3, 0, 2, 10, 16, 6, 47, 0, 5, 31, 0, 2, 8
OFFSET
0,7
COMMENTS
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.
LINKS
EXAMPLE
a(3) = 1 as there is 1 term between a(3-1) = a(2) = 0 and a(0) = 0.
a(5) = 0 as there are no terms between a(5-1) = a(4) = 1 and a(3) = 1.
a(7) = 0 as a(7-1) = a(6) = 2 has only appeared once up to n = 7.
a(12) = 4 as there are 4 terms between a(12-1) = a(11) = 2 and a(6) = 2.
a(22) = 11 as there are 11 terms between a(22-1) = a(21) = 3 and a(9) = 3.
MAPLE
a:= proc(n) option remember; local t, j;
if n<2 then n else t:= a(n-1);
for j from 2 to n do
if a(n-j)=t then return j-2 fi
od; 0
fi
end:
seq(a(n), n=0..100); # Alois P. Heinz, Oct 04 2019
MATHEMATICA
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 *)
CROSSREFS
Sequence in context: A022880 A366614 A128097 * A353778 A173662 A263406
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Oct 04 2019
STATUS
approved