login
Smallest k such that 3^k has exactly n 0's in its decimal representation.
12

%I #24 Jun 15 2018 08:23:21

%S 0,10,22,21,35,57,55,54,107,137,126,170,188,159,191,225,259,297,262,

%T 253,340,296,380,369,403,395,383,407,429,514,446,486,431,545,589,510,

%U 546,542,666,733,540,621,709,715,549,694,804,820,847,865,710

%N Smallest k such that 3^k has exactly n 0's in its decimal representation.

%H Robert Israel, <a href="/A063555/b063555.txt">Table of n, a(n) for n = 0..2000</a>

%p N:= 100: # to get a(0)..a(N)

%p A:= Array(0..N,-1):

%p p:= 1: A[0]:= 0:

%p count:= 1:

%p for k from 1 while count <= N do

%p p:= 3*p;

%p m:= numboccur(0, convert(p,base,10));

%p if m <= N and A[m] < 0 then A[m]:= k; count:= count+1 fi

%p od:

%p seq(A[i],i=0..N); # _Robert Israel_, Dec 21 2016

%t a = {}; Do[k = 1; While[ Count[ IntegerDigits[3^k], 0] != n, k++ ]; a = Append[a, k], {n, 0, 50} ]; a

%t Module[{l3=Table[{n,DigitCount[3^n,10,0]},{n,900}]},Transpose[Table[ SelectFirst[ l3,#[[2]]==i&],{i,0,50}]][[1]]] (* _Harvey P. Dale_, Dec 08 2014 *)

%o (PARI) A063555(n)=for(k=0,oo,#select(d->!d,digits(3^k))==n&&return(k)) \\ _M. F. Hasler_, Jun 14 2018

%Y Cf. A000244.

%Y Cf. A031146 (analog for 2^k), A063575 (analog for 4^k).

%K base,nonn

%O 0,2

%A _Robert G. Wilson v_, Aug 10 2001

%E a(0) corrected by _Zak Seidov_, Jun 14 2018