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”).
%I #8 May 26 2015 10:28:54
%S 0,1,0,0,0,1,0,0,0,1,0,0,1,2,0,1,1,1,1,0,1,3,2,1,1,1,1,0,0,4,1,3,1,1,
%T 0,1,1,3,1,1,0,3,2,3,2,4,1,2,3,4,0,4,2,3,3,0,7,2,2,4,4,3,2,3,4,5,6,2,
%U 4,8,3,1,2,6,3,4,5,4,3,2,6,5,4,8,0,4,4,7,2,4,3,6,5,8,5,3,7,3,2,4,5
%N Number of 3's in decimal expansion of 3^n, with n>=0.
%e a(21)=3 because 3^21=10460353203 with three 3's.
%p P:=proc(n) local i,k,x,y,w,cont; y:=3; k:=y; for i from 0 by 1 to n do x:=y^i; cont:=0; while x>0 do w:=x-trunc(x/10)*10; if w=k then cont:=cont+1; fi; x:=trunc(x/10); od; print(cont); od; end: P(100);
%t DigitCount[3^Range[0,100],10,3] (* _Harvey P. Dale_, May 26 2015 *)
%Y Cf. A065710, A126206, A126207, A126208, A126209, A126210, A126211.
%K nonn,base
%O 0,14
%A _Paolo P. Lava_ and _Giorgio Balzarotti_, Dec 20 2006