OFFSET
0,1
COMMENTS
a(n) is well-defined for all n, because 2^k can actually start with (not just contain) any finite sequence of digits without leading zeros. This follows from the facts that log_10(2) is irrational and that the set of fractional parts of n*x is dense in [0,1] if x is irrational. - Pontus von Brömssen, Jul 21 2021
LINKS
Giovanni Resta, Table of n, a(n) for n = 0..10000 (terms up to a(1000) from T. D. Noe, a(9634) corrected by Piotr Idzik)
FORMULA
a(n) <= A018856(n) for n >= 1. - Pontus von Brömssen, Jul 21 2021
EXAMPLE
2^12 = 4096 is first power of 2 containing a 9, so a(9) = 12.
MATHEMATICA
Table[ i=0; While[ StringPosition[ ToString[ 2^i ], ToString[ n ] ]=={}, i++ ]; i, {n, 0, 80} ]
PROG
(Haskell)
import Data.List (isInfixOf, findIndex)
import Data.Maybe (fromJust)
a030000 n =
fromJust $ findIndex (show n `isInfixOf`) $ map show a000079_list
-- Reinhard Zumkeller, Aug 04 2011
(PARI) a(n) = {if (n==1, return (0)); my(k=1, sn = Str(n)); while (#strsplit(Str(2^k), sn) == 1, k++); k; } \\ Michel Marcus, Mar 06 2021
(PARI) apply( A030000(n)={n=Str(n); for(k=0, oo, #strsplit(Str(2^k), n)>1&& return(k))}, [0..99]) \\ Also allows to search for digit strings with leading zeros, e.g., "00" => k=53. - M. F. Hasler, Jul 11 2021
(Python)
def a(n):
k, strn = 0, str(n)
while strn not in str(2**k): k += 1
return k
print([a(n) for n in range(74)]) # Michael S. Branicky, Mar 06 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
More terms from Hans Havermann
STATUS
approved