login
"Look once to the left" sequence, omitting a(k) for each iteration k, starting with 1,2 (see example).
0

%I #24 Aug 21 2021 00:15:59

%S 1,2,2,1,2,1,2,1,2,1,2,2,2,1,2,1,2,1,2,2,1,1,2,1,2,1,2,2,2,1,2,1,2,1,

%T 2,2,1,2,2,1,2,1,2,2,2,1,2,1,2,1,2,2,1,1,2,1,2,1,2,2,2,1,2,1,2,1,2,2,

%U 1,2,1,1,2,1,2,2,2,1,2,1,2,1,2,2,1,1,2

%N "Look once to the left" sequence, omitting a(k) for each iteration k, starting with 1,2 (see example).

%C The ratio of number of 2's to number of 1's appears to converge to 1.3985918...

%e Begin with [1, 2].

%e Iteration 1: append to self, omitting term 1: [1, 2] + [2] = [1, 2, 2].

%e Iteration 2: append to self, omitting term 2: [1, 2, 2] + [1, 2] = [1, 2, 2, 1, 2].

%e Iteration 3: append to self, omitting term 3: [1, 2, 2, 1, 2] + [1, 2, 1, 2] = [1, 2, 2, 1, 2, 1, 2, 1, 2].

%t Block[{a = {1, 2}}, Do[a = Join[a, Delete[a, i]], {i, 7}]; a] (* _Michael De Vlieger_, Aug 04 2021 *)

%o (Python)

%o def sequence(iterations, start=[1,2]):

%o a = start

%o for k in range(0, iterations):

%o a = a + a[:k] + a[k+1:]

%o return a

%o (PARI) a(n) = n-=2; while(n>0, my(k=logint(n,2)); n-=1<<k; if(n<k,n--)); n+2; \\ _Kevin Ryde_, Aug 03 2021

%Y Cf. A000051, A293838.

%K nonn

%O 1,2

%A _Matthew Malone_, Jul 29 2021