%I #26 Sep 08 2024 13:50:41
%S 4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,3,4,3,3,
%T 4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,3,4,3,3,4,3,3,4,3,3,
%U 4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,4,3,3,3,4,3,3
%N a(n) is the number of powers of 2 that have n decimal digits.
%C Ignoring the first term, first differences of A066343. - _Andrew Woods_, Jun 10 2013
%H Amiram Eldar, <a href="/A129344/b129344.txt">Table of n, a(n) for n = 1..10000</a>
%F For n>1, a(n) = floor(n*L)-floor((n-1)*L) where L = log(10)/log(2). - _Andrew Woods_, Jun 10 2013
%F Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = log_2(10) (A020862). - _Amiram Eldar_, Apr 09 2021
%e a(1) is 4 because there are 4 one-digit powers of 2: 1, 2, 4, 8.
%t Table[Transpose[ Select[Table[{n, 2^n}, {n, 0, 310}], IntegerDigits[ #[[2]]][[1]] == 1 &]][[1]][[k]] - Transpose[ Select[Table[{n, 2^n}, {n, 0, 310}], IntegerDigits[ #[[2]]][[1]] == 1 &]][[1]][[k - 1]], {k, 2, 94}]
%t Join[{4}, Differences @ Table[Floor[n*Log2[10]], {n, 100}]] (* _Amiram Eldar_, Apr 09 2021 *)
%o (PARI) a(n) = my(k=0, i=0); while(#Str(2^k)!=n, k++); while(#Str(2^k)==n, i++; k++); i \\ _Felix Fröhlich_, Jan 19 2016
%o (Python)
%o def A129344(n): return -(m:=5**(n-1)).bit_length()+(5*m).bit_length()+1 if n>1 else 4 # _Chai Wah Wu_, Sep 08 2024
%Y First differences of A067497.
%Y Cf. A000079, A020862, A066343.
%K base,nonn
%O 1,1
%A _Tanya Khovanova_, May 28 2007