cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A062520 3^a(n) is smallest nonnegative power of 3 containing n.

This page as a plain text file.
%I A062520 #15 Oct 04 2021 09:25:56
%S A062520 10,0,3,1,5,8,8,3,4,2,21,19,17,22,11,13,17,11,7,9,18,7,19,13,5,26,19,
%T A062520 3,24,6,16,12,13,31,15,21,24,29,18,31,17,12,18,5,12,28,16,11,15,10,35,
%U A062520 32,33,12,26,27,8,40,26,10,21,8,19,17,24,8,33,16,9,14,35,11,6,29,18,47
%N A062520 3^a(n) is smallest nonnegative power of 3 containing n.
%H A062520 Robert Israel, <a href="/A062520/b062520.txt">Table of n, a(n) for n = 0..9999</a>
%e A062520 a(1) = 0 since 3^0 = 1. a(2) = a(7) = a(27) = 3 because 3^3 = 27.
%p A062520 N:= 99:
%p A062520 count:= 1: A["0"]:= 10:
%p A062520 for n from 0 while count <= N do
%p A062520   S:= convert(3^n,string); nS:= length(S);
%p A062520   for m from 1 to 2 while count <= N do
%p A062520     for i from 1 to nS+1-m while count <= N do
%p A062520       if S[i] <> "0" and not assigned(A[S[i..i+m-1]]) then
%p A062520          count:= count+1; A[S[i..i+m-1]]:= n;
%p A062520       fi
%p A062520     od
%p A062520   od
%p A062520 od:
%p A062520 seq(A[convert(n,string)],n=0..N); # _Robert Israel_, Jun 14 2018
%t A062520 Table[k = 0; While[ StringPosition[ ToString[3^k], ToString[n] ] == {}, k++ ]; k, {n, 0, 75} ]
%o A062520 (Python)
%o A062520 def a(n):
%o A062520     s, k = str(n), 0
%o A062520     while s not in str(3**k): k += 1
%o A062520     return k
%o A062520 print([a(n) for n in range(76)]) # _Michael S. Branicky_, Oct 04 2021
%Y A062520 Cf. A030000. Essentially the same as A063566. Cf. A000244.
%K A062520 base,nonn
%O A062520 0,1
%A A062520 _Robert G. Wilson v_, Jun 24 2001