|
|
A365458
|
|
The largest power of 3 that is less than or equal to n.
|
|
3
|
|
|
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
|
|
|
FORMULA
|
|
|
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
|
|
|
PROG
|
(PARI) A365458(n) = if(1==n, n, my(k=0); while((3^k) < n, k++); if((3^k) > n, k--); (3^k));
(Python)
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|