login
Least power of 3 having exactly n consecutive 2's in its decimal representation.
9

%I #13 Mar 19 2021 10:22:05

%S 3,19,148,253,330,2380,2124,30598,22791,238582,107187,1521134,

%T 10363119,9995030,68353787

%N Least power of 3 having exactly n consecutive 2's in its decimal representation.

%e a(3)=148 because 3^148 (i.e. 41109831670569663658300086939077404909608122265524774868353822811305361) is the smallest power of 3 to contain a run of 3 consecutive twos in its decimal form.

%t a = ""; Do[ a = StringJoin[a, "2"]; b = StringJoin[a, "2"]; k = 1; While[ StringPosition[ ToString[3^k], a] == {} || StringPosition[ ToString[3^k], b] != {}, k++ ]; Print[k], {n, 1, 10} ]

%o (Python)

%o def a(n):

%o k, n2, np2 = 1, '2'*n, '2'*(n+1)

%o while True:

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

%o if np2 not in str(3**k): return k

%o k += 1

%o print([a(n) for n in range(1, 8)]) # _Michael S. Branicky_, Mar 19 2021

%Y Cf. A195269, A131552, A131550, A131549, A131548, A131547, A131546, A131545, A131544.

%K more,nonn,base

%O 1,1

%A _Shyam Sunder Gupta_, Aug 26 2007

%E a(11)-a(14) from _Lars Blomberg_, Feb 02 2013

%E a(15) from _Bert Dobbelaere_, Mar 04 2019