%I
%S 1,2,1,2,2,1,3,2,3,2,2,1,6,4,5,1,4,3,9,6,7,1,6,3,6,2,15,8,7,8,2,5,17,
%T 6,9,16,9,2,7,10,3,17,9,6,10,5,14,2,10,4,33,9,9,1,32,13,7,18,16,23,2,
%U 13,6,19,6,2,5,21,4,19,6,6,1,19,4,6,4,2,12,30
%N Set a(1)=1 and a(2)=2. For n > 2, if a(n) had already appeared in the sequence, then a(n+1) = number of steps since its most recent appearance, as in Van Eck's sequence A181391. If a(n) had not appeared before, search instead for a(n)1, then a(n)2, etc., until you find a number that has appeared before.
%C In other words, let a(1)=1, a(2)=2, and for any n >= 2, let v be the greatest value <= a(n) among the first n1 terms; a(n+1) is the least d > 0 such that a(nd) = v.
%H Rémy Sigrist, <a href="/A328294/b328294.txt">Table of n, a(n) for n = 1..25000</a>
%e We start with a(1) = 1 and a(2) = 2. 2 has not appeared before, so we search for the greatest valid integer less than 2, which in this case is 1. 1 last occurred at a(1), which is 1 term before, so a(3) = 1.
%e 1 occurred 2 terms before, so a(4) = 2.
%e 2 appeared at term a(2), which is 2 terms before, so a(5) = 2.
%e 2 appeared most recently at term a(5), which is 1 term earlier, so a(6) = 1.
%e And so on.
%o (PARI) seq(n)={my(a=vector(n)); a[1]=1; a[2]=2; for(n=2, n1, my(m=1); for(i=2, n1, if(a[i] <= a[n] && a[i] >= a[m], m=i)); a[n+1]=nm); a} \\ _Andrew Howroyd_, Oct 25 2019
%Y Cf. A181391, A171911.
%K nonn
%O 1,2
%A _Robin Powell_, Oct 11 2019
