OFFSET
1,4
COMMENTS
Distance to next number of form 2^k-1, written down in binary, then interpreted as ternary. Thus the numbers have no 2 in ternary representation.
LINKS
FORMULA
a(1)=0, a(2n) = 3a(n)+1, a(2n+1) = 3a(n).
a(n) = (1/2)*(3^(floor(log_2(n))+1)-1) - A005836(n).
PROG
(PARI) for(n=1, 100, l=ceil(log(n)/log(2)); t=polcoeff(1/(1-x)*sum(k=0, l, 3^k*(x^2^(k+1))/(1+x^2^k)) + O(x^(n+1)), n); print1(t", "))
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ralf Stephan, Jun 18 2003
STATUS
approved