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.
%I A365458 #22 Sep 17 2023 18:27:42 %S A365458 1,1,3,3,3,3,3,3,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,27,27,27,27,27, %T A365458 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27, %U A365458 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,81,81,81,81,81 %N A365458 The largest power of 3 that is less than or equal to n. %H A365458 Michael De Vlieger, <a href="/A365458/b365458.txt">Table of n, a(n) for n = 1..19683</a> (3^9 = 19683) %F A365458 a(n) = 3^floor((log n) / (log 3)). - _Michael De Vlieger_, Sep 17 2023 %F A365458 a(n) = A000244(A062153(n)). - _Michel Marcus_, Sep 17 2023 %e A365458 a(2) = 1 because 3^0 = 1 <= 2. %e A365458 a(3) = 3 because 3^1 = 3 <= 3. %e A365458 a(4) = 3 because 3^1 = 3 <= 4. %t A365458 Array[3^Floor@ Log[3, #] &, 90] (* _Michael De Vlieger_, Sep 17 2023 *) %o A365458 (PARI) A365458(n) = if(1==n,n,my(k=0); while((3^k) < n, k++); if((3^k) > n,k--); (3^k)); %o A365458 (PARI) a(n) = 3^logint(n, 3); \\ _Michel Marcus_, Sep 17 2023 %o A365458 (Python) %o A365458 def A365458(n): %o A365458 kmin, kmax = 0, 1 %o A365458 while 3**kmax <= n: %o A365458 kmax <<= 1 %o A365458 while True: %o A365458 kmid = kmax+kmin>>1 %o A365458 if 3**kmid > n: %o A365458 kmax = kmid %o A365458 else: %o A365458 kmin = kmid %o A365458 if kmax-kmin <= 1: %o A365458 break %o A365458 return 3**kmin # _Chai Wah Wu_, Sep 17 2023 %Y A365458 Cf. A000244, A365459. %Y A365458 Cf. also A062153, A064235, A080342. %K A365458 nonn %O A365458 1,3 %A A365458 _Antti Karttunen_, Sep 17 2023