OFFSET
0,4
COMMENTS
Sequence generalized : a(n) = A^n - B^(floor(log_B (A^n))) where A, B are integers. This sequence has A = 2, B = 3; A056577 has A = 3, B = 2. - Ctibor O. Zizka, Mar 03 2008
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..3324
FORMULA
a(n) = 2^n - 3^(floor (log_3 (2^n))).
MAPLE
a:= n-> (t-> t-3^ilog[3](t))(2^n):
seq(a(n), n=0..40); # Alois P. Heinz, Oct 11 2019
MATHEMATICA
a[n_] := 2^n - 3^Floor[Log[3, 2] * n]; Array[a, 36, 0] (* Amiram Eldar, Nov 19 2021 *)
PROG
(PARI) for(n=0, 50, print1(2^n-3^floor(log(2^n)/log(3))", "))
(Python)
def a(n):
m, p, target = 0, 1, 2**n
while p <= target: m += 1; p *= 3
return target - 3**(m-1)
print([a(n) for n in range(36)]) # Michael S. Branicky, Nov 19 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jens Voß, Jul 02 2001
EXTENSIONS
More terms from Ralf Stephan, Mar 20 2003
STATUS
approved