OFFSET
0,1
LINKS
Robert Israel, Table of n, a(n) for n = 0..9999
EXAMPLE
a(1) = 0 since 3^0 = 1. a(2) = a(7) = a(27) = 3 because 3^3 = 27.
MAPLE
N:= 99:
count:= 1: A["0"]:= 10:
for n from 0 while count <= N do
S:= convert(3^n, string); nS:= length(S);
for m from 1 to 2 while count <= N do
for i from 1 to nS+1-m while count <= N do
if S[i] <> "0" and not assigned(A[S[i..i+m-1]]) then
count:= count+1; A[S[i..i+m-1]]:= n;
fi
od
od
od:
seq(A[convert(n, string)], n=0..N); # Robert Israel, Jun 14 2018
MATHEMATICA
Table[k = 0; While[ StringPosition[ ToString[3^k], ToString[n] ] == {}, k++ ]; k, {n, 0, 75} ]
PROG
(Python)
def a(n):
s, k = str(n), 0
while s not in str(3**k): k += 1
return k
print([a(n) for n in range(76)]) # Michael S. Branicky, Oct 04 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Robert G. Wilson v, Jun 24 2001
STATUS
approved