OFFSET
1,5
COMMENTS
Sequence is similar to A181391 except that the "count back" following a repeated term is 1 less, and the term following a first occurrence is 1 rather than 0. The plots are similar to those of the Van Eck sequence.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..10000
Michael De Vlieger, Annotated scatterplot of a(n) for n = 1..256, showing records in red, terms otherwise appearing for the first time in green, zeros in blue, and indicating the smallest missing number in gold.
Michael De Vlieger, Scatterplot of a(n) for n = 1..16384 showing records in red and zeros in blue, and indicating the smallest missing number in gold.
Michael De Vlieger, Log-log scatterplot of a(n) for n = 1..2^20 showing records in red and indicating the smallest missing number in gold (ignoring zeros).
EXAMPLE
We start with a(1)=0, which has not appeared before, so a(2)=1, Likewise 1 has not appeared before so a(3) is also 1, which is a repeat term, last seen at a(2). Since there are no terms between the last two 1s, we have a(4)=0. We now have 0,1,1,0 and so a(5)=2, the number of terms between repetitions of zero. The only way a 0 appears in the sequence is as a consequence of adjacent identical terms k,k.
MAPLE
M := 100; # Adapted from the Maple program in A181391.
a := Array(1 .. M);
last := Array(0 .. M, -1);
m := M-1;
a[1] := 0;
a[2] := 1;
last[0] := 2;
nxt := 1;
for n from 3 to M do
hist := last[nxt];
a[n-1] := nxt;
last[nxt] := n;
nxt := 1;
if hist > 0 then nxt := n-hist-1; fi;
od:
[seq(a[n], n = 1 .. m)]
MATHEMATICA
a = {0}; Do[(AppendTo[a, If[IntegerQ@ c[#], i - c[#] - 1, 1]]; Set[c[#], i]) &@ a[[-1]], {i, 2, 83}]; a (* Michael De Vlieger, Feb 16 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
David James Sycamore, Feb 13 2022
STATUS
approved