%I #11 Apr 09 2023 02:29:13
%S 0,1,1,1,2,3,1,5,2,4,4,1,10,5,6,7,1,15,5,11,7,5,14,3,18,7,10,14,5,21,
%T 5,23,2,28,2,30,2,32,2,34,2,36,2,38,2,40,2,42,2,44,2,46,2,48,2,50,2,
%U 52,2,54,2,56,2,58,2,60,2,62,2,64,2,66,2,68,2,70,2
%N Set a(1)=0 and a(2)=1. For n > 1, if a(n) has already appeared in the sequence, then a(n+1) = number of steps since its first appearance. If a(n) has not appeared before, search instead for a(n)-1, then a(n)-2, etc., until you find a number that has appeared before.
%C The first 32 terms are distributed chaotically, after which the sequence alternates between 2 and n-6 indefinitely.
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (0,2,0,-1).
%e We start with a(1) = 0 and a(2) = 1. 1 has not appeared before, so we search for the greatest valid integer less than 1, which in this case is 0. 0 first occurred at a(1), which is 1 term before a(2) so a(3) = 1.
%e 1 first occurred 1 term before, so a(4) = 1.
%e 1 appeared at term a(1), which is 2 terms before a(4), so a(5) = 2.
%e 2 has not appeared before, so we search for 1, which occurred 3 terms before at a(1). a(6) = 3.
%e And so on.
%Y Cf. A328294, A181391.
%K nonn,easy
%O 1,5
%A _Robin Powell_, Mar 17 2023