login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Smallest power of 3 whose decimal expansion contains n.
12

%I #18 Apr 03 2024 10:06:35

%S 59049,1,27,3,243,6561,6561,27,81,9,10460353203,1162261467,129140163,

%T 31381059609,177147,1594323,129140163,177147,2187,19683,387420489,

%U 2187,1162261467,1594323,243,2541865828329,1162261467,27,282429536481,729,43046721,531441,1594323

%N Smallest power of 3 whose decimal expansion contains n.

%C This is to 3 as A030001 is to 2.

%H Paolo Xausa, <a href="/A176763/b176763.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = MIN{A000244(i) such that n in decimal representation is a substring of A000244(i)}.

%e a(1) = 1 because 3^0 = 1 has "1" as a substring (not a proper substring, though).

%e a(2) = 27 because 3^3 = 27 has "2" as a substring.

%e a(10) = 10460353203 because 3^21 = 10460353203 is the smallest power of 3 whose decimal expansion contains "10" (in this case, "10" happens to be the left-hand or initial digits, but that is not generally true).

%t A176763[n_] := Block[{k = -1}, While[StringFreeQ[IntegerString[3^++k], IntegerString[n]]]; 3^k]; Array[A176763, 50, 0] (* _Paolo Xausa_, Apr 03 2024 *)

%o (Python)

%o def a(n):

%o k, strn = 0, str(n)

%o while strn not in str(3**k): k += 1

%o return 3**k

%o print([a(n) for n in range(33)]) # _Michael S. Branicky_, Apr 03 2024

%Y Cf. A000244, A030000, A030001, A063565, A018856.

%K base,easy,nonn

%O 0,1

%A _Jonathan Vos Post_, Apr 25 2010

%E More terms from _Sean A. Irvine_ and _Jon E. Schoenfield_, May 05 2010

%E a(0) prepended by _Paolo Xausa_, Apr 03 2024