%I #30 Jan 27 2022 22:47:53
%S 2,1,1,2,2,1,2,1,2,1,1,1,1,1,2,1,1,1,2,1,1,1,1,1,2,2,1,1,2,1,1,2,1,2,
%T 1,1,1,2,1,2,1,2,2,1,1,2,1,2,2,2,1,1,1,1,2,2,1,2,1,1,1,2,2,2,1,2,1,1,
%U 2,2,2,1,2,2,1,1,2,1,1,1,2,1,1,2,1,2,1,1,2,2,1,1,2,1,1,2,1,1,2,1,2,1,2,1,2,1,1,1
%N If any odd power of 2 ends with k 1's and 2's, they must be the first k terms of this sequence in reverse order.
%H David A. Corneth, <a href="/A023396/b023396.txt">Table of n, a(n) for n = 1..10000</a>
%e 2^1 ends in 2;
%e 2^5 ends in 32;
%e 2^9 ends in 512;
%e 2^13 ends in 8192;
%e 2^89 ends in ...562112.
%e There exists a power of two ending in 12, so for n = 3 the choice for a(3) = 1 or a(3) = 2 comes from the existence of a power of two ending in either 112 or 212. As 112 is divisible by 2^n = 8 (and 212 is not) a(3) = 1. - _David A. Corneth_, Jun 11 2020
%o (PARI) first(n) = my(f = 2, pow10 = 1, pow2 = 2); { for(i = 2, n, pow10*=10; pow2<<=1; c1 = pow10 + f; if(c1 % pow2 == 0, f = c1, c2 = 2*pow10 + f; if(c2 % pow2 == 0, f = c2 ) ) ); Vecrev(digits(f)) } \\ _David A. Corneth_, Jun 11 2020
%Y Cf. A053312, A126933.
%K nonn,easy,base
%O 1,1
%A _David W. Wilson_
%E Definition corrected by _Gerry Leversha_, Mar 17 2007