login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A365458 The largest power of 3 that is less than or equal to n. 2
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..19683 (3^9 = 19683)
FORMULA
a(n) = 3^floor((log n) / (log 3)). - Michael De Vlieger, Sep 17 2023
a(n) = A000244(A062153(n)). - Michel Marcus, Sep 17 2023
EXAMPLE
a(2) = 1 because 3^0 = 1 <= 2.
a(3) = 3 because 3^1 = 3 <= 3.
a(4) = 3 because 3^1 = 3 <= 4.
MATHEMATICA
Array[3^Floor@ Log[3, #] &, 90] (* Michael De Vlieger, Sep 17 2023 *)
PROG
(PARI) A365458(n) = if(1==n, n, my(k=0); while((3^k) < n, k++); if((3^k) > n, k--); (3^k));
(PARI) a(n) = 3^logint(n, 3); \\ Michel Marcus, Sep 17 2023
(Python)
def A365458(n):
kmin, kmax = 0, 1
while 3**kmax <= n:
kmax <<= 1
while True:
kmid = kmax+kmin>>1
if 3**kmid > n:
kmax = kmid
else:
kmin = kmid
if kmax-kmin <= 1:
break
return 3**kmin # Chai Wah Wu, Sep 17 2023
CROSSREFS
Cf. also A062153, A064235, A080342.
Sequence in context: A343515 A351836 A105159 * A334625 A209291 A332875
KEYWORD
nonn
AUTHOR
Antti Karttunen, Sep 17 2023
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 12 16:19 EDT 2024. Contains 372492 sequences. (Running on oeis4.)