login
Numbers k such that 3 is the first digit of 2^k.
7

%I #35 Nov 13 2023 10:01:39

%S 5,15,25,35,45,55,65,75,78,85,88,95,98,108,118,128,138,148,158,168,

%T 178,181,188,191,201,211,221,231,241,251,261,271,274,281,284,291,294,

%U 304,314,324,334,344,354,364,367,374,377,384,387,397,407,417,427,437,447,457,467,470,477,480,487,490,500

%N Numbers k such that 3 is the first digit of 2^k.

%C The asymptotic density of this sequence is log_10(4/3) = 0.124938... - _Amiram Eldar_, Jan 27 2021

%H Seiichi Manyama, <a href="/A172404/b172404.txt">Table of n, a(n) for n = 1..10000</a> (first 4200 terms from Muniru A Asiru)

%p x := 1.; L := []; for n from 0 to 500 do if 3 < x and x < 4 then L := [op(L), n] end if; x := 2*x; if x > 10 then x := (1/10)*x end if end do; L;

%t Select[Range[1000], IntegerDigits[2^#][[1]] == 3 &]

%o (Python)

%o ans, x = [], 1.

%o for n in range(501):

%o if 3 < x < 4: ans.append(n)

%o x = x*2

%o if x > 10: x = x / 10

%o print(ans)

%o (Python)

%o from itertools import islice

%o def A172404_gen(): # generator of terms

%o a, b, c, l = 3, 4, 1, 0

%o while True:

%o if a<=c:

%o if c<b:

%o yield l

%o a *= 10

%o b *= 10

%o c <<= 1

%o l += 1

%o A172404_list = list(islice(A172404_gen(),30)) # _Chai Wah Wu_, Nov 13 2023

%o (GAP) Filtered([1..500],n->ListOfDigits(2^n)[1]=3); # _Muniru A Asiru_, Oct 17 2018

%o (PARI) isok(n) = digits(2^n)[1] == 3; \\ _Michel Marcus_, Oct 18 2018

%Y Cf. A000079.

%Y Cf. A067497, A067469, A367294, A363060, A367295, A330243, A367296, A097415.

%K nonn,base,easy

%O 1,1

%A _David Radcliffe_, Nov 20 2010