%I #44 Aug 06 2021 13:06:50
%S 12,53,53,232,93,1862,93,3244,93,93,93,55754,12864,55756,23353,361353,
%T 16441,361353,304362,361353,361353,361353,361353,3748854,3748854,
%U 78055893,66290232,119133355,119133355,379371432,20958353,130883333,20958353,130883333
%N Least k such that at least half of the last n digits of 2^k are 9.
%C See the Mathematical Reflections link for a proof that a(n) exists for all n>1.
%H Jon E. Schoenfield and Chai Wah Wu, <a href="/A280660/b280660.txt">Table of n, a(n) for n = 2..44</a> (terms for n = 2..42 from Jon E. Schoenfield)
%H Mathematical Reflections, <a href="https://www.awesomemath.org/wp-pdf-files/math-reflections/mr-2014-06/mr_5_2014_solutions-3.pdf">Solution to Problem O316</a>, Issue 6, 2014, p 26.
%H Jon E. Schoenfield, <a href="/A280660/a280660.txt">Magma program</a>
%e For n=2, k=12 with 2^k = 4096.
%p a:= proc(n) local m, t, k, c, h; m, t:= 10^n, 2048;
%p for k from 12 do t:= 2*t mod m; h, c:= t, 0;
%p while h>0 do if irem(h, 10, 'h')=9 then c:= c+2 fi od;
%p if c >= n then return k fi
%p od
%p end:
%p seq(a(n), n=2..16); # _Alois P. Heinz_, Jan 07 2017
%o (PARI) a(n) = my(k = 1, ok = 0); until (ok, vd = Vecrev(digits(2^k)); nb = sum(j=1, min(n, #vd), vd[j]==9); ok = (nb >= n/2); if (! ok, k++);); k;
%o (Python)
%o def A280660(n):
%o m, k, l = 10**n,1,2
%o while True:
%o if 2*str(l).count('9') >= n:
%o return k
%o k += 1
%o l = (l*2) % m # _Chai Wah Wu_, Jan 07 2017
%K nonn,base
%O 2,1
%A _Michel Marcus_, Jan 07 2017
%E a(17)-a(30) from _Alois P. Heinz_, Jan 07 2017
%E a(31)-a(35) from _Jon E. Schoenfield_, Jan 07 2017