login
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

%I #28 Feb 09 2023 22:09:23

%S 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,

%T 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,

%U 12,6,22,1,8,1,1,0,43,1,2,13,1,2,2,0,7,16,33

%N 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.

%C 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.

%H Michael De Vlieger, <a href="/A341094/b341094.txt">Table of n, a(n) for n = 1..10000</a>

%H Michael De Vlieger, <a href="/A341094/a341094.png">Annotated scatterplot of a(n)</a> 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.

%H Michael De Vlieger, <a href="/A341094/a341094_1.png">Scatterplot of a(n)</a> for n = 1..16384 showing records in red and zeros in blue, and indicating the smallest missing number in gold.

%H Michael De Vlieger, <a href="/A341094/a341094_2.png">Log-log scatterplot of a(n)</a> for n = 1..2^20 showing records in red and indicating the smallest missing number in gold (ignoring zeros).

%e 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.

%p M := 100; # Adapted from the Maple program in A181391.

%p a := Array(1 .. M);

%p last := Array(0 .. M, -1);

%p m := M-1;

%p a[1] := 0;

%p a[2] := 1;

%p last[0] := 2;

%p nxt := 1;

%p for n from 3 to M do

%p hist := last[nxt];

%p a[n-1] := nxt;

%p last[nxt] := n;

%p nxt := 1;

%p if hist > 0 then nxt := n-hist-1; fi;

%p od:

%p [seq(a[n], n = 1 .. m)]

%t 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 *)

%Y Cf. A181391.

%K nonn

%O 1,5

%A _David James Sycamore_, Feb 13 2022