OFFSET
0,3
COMMENTS
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 0..10000
FORMULA
a(0) = 0, a(2*n) = 2*a(n), and a(2*n+1) = a(n) + 3^A000120(n).
EXAMPLE
a(0) = 0.
a(1) = a(2*0+1) = a(0) + 3^A000120(0) = 0 + 3^0 = 1.
a(2) = a(2*1) = 2*a(1) = 2*1 = 2.
a(3) = a(2*1+1) = a(1) + 3^A000120(1) = 1 + 3^1 = 4.
a(4) = a(2*2) = 2*a(2) = 2*2 = 4.
a(5) = a(2*2+1) = a(2) + 3^A000120(2) = 2 + 3^1 = 5.
a(6) = a(2*3) = 2*a(3) = 2*4 = 8.
a(7) = a(2*3+1) = a(3) + 3^A000120(3) = 4 + 3^2 = 13.
a(8) = a(2*4) = 2*a(4) = 2*4 = 8.
PROG
(Python)
def h(n):
if(n == 0): return 0
elif(n%2 == 0): return h(n/2)
else: return h((n-1)/2) + 1
def a(n):
if(n == 0): return 0
elif(n%2 == 0): return 2*a(n/2)
else: return a((n-1)/2) + 3**h((n-1)/2)
(PARI) h(n)=if(n, n>>=valuation(n, 2); h(n\2)+1, 0)
a(n)=if(n, my(k=valuation(n, 2)); n>>=k+1; (a(n)+3^h(n))<<k, 0) \\ Charles R Greathouse IV, Aug 18 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jared Deckard, Aug 17 2015
STATUS
approved