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”).

A126205
Number of 3's in decimal expansion of 3^n, with n>=0.
6
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, 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, 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
OFFSET
0,14
EXAMPLE
a(21)=3 because 3^21=10460353203 with three 3's.
MAPLE
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);
MATHEMATICA
DigitCount[3^Range[0, 100], 10, 3] (* Harvey P. Dale, May 26 2015 *)
KEYWORD
nonn,base
AUTHOR
STATUS
approved