[go: up one dir, main page]

login
A341094
a(1) = 0. Thereafter, if a(n) has appeared before, most recently at a(m), then a(n+1) = n-m-1, the number of terms between a(m) and a(n). Otherwise a(n+1)=1.
2
0, 1, 1, 0, 2, 1, 2, 1, 1, 0, 5, 1, 2, 5, 2, 1, 3, 1, 1, 0, 9, 1, 2, 7, 1, 2, 2, 0, 7, 4, 1, 5, 17, 1, 2, 7, 6, 1, 3, 21, 1, 2, 6, 5, 11, 1, 4, 16, 1, 2, 7, 14, 1, 3, 14, 2, 5, 12, 1, 5, 2, 4, 14, 7, 12, 6, 22, 1, 8, 1, 1, 0, 43, 1, 2, 13, 1, 2, 2, 0, 7, 16, 33
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, 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
Cf. A181391.
Sequence in context: A029416 A252374 A344569 * A346831 A161780 A136571
KEYWORD
nonn
AUTHOR
STATUS
approved