

A233931


a(2n) = a(n) + n, a(2n+1) = a(n), with a(0)=0.


3



0, 0, 1, 0, 3, 1, 3, 0, 7, 3, 6, 1, 9, 3, 7, 0, 15, 7, 12, 3, 16, 6, 12, 1, 21, 9, 16, 3, 21, 7, 15, 0, 31, 15, 24, 7, 30, 12, 22, 3, 36, 16, 27, 6, 34, 12, 24, 1, 45, 21, 34, 9, 42, 16, 30, 3, 49, 21, 36, 7, 45, 15, 31, 0, 63, 31, 48, 15, 58, 24, 42, 7, 66, 30, 49, 12, 60, 22, 42, 3, 76, 36, 57
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,5


COMMENTS

For every zero bit in the binary representation of n, add the number represented by the substring left of it.


LINKS

Antti Karttunen, Table of n, a(n) for n = 0..8192
Index entries for sequences related to binary expansion of n


FORMULA

a(n) = sum(k=0..floor(log(n)/log(2)), (1bittest(n,k)) * floor(n/2^(k+1)) ) = sum(k=0..A000523(n), !A030308(n,k+1) * floor(n/2^(k+1)) ), with bittest(n,k)=0 or 1 according to the kth bit of n (the zeroth bit the least significant).
a(n) = A011371(n)  A233905(n).


EXAMPLE

17 is 10001 in binary, so we add 1, 10=2, and 100=4 so a(17)=7.
27 is 11011 in binary, so we add 11=3, so a(27)=3.


PROG

(PARI) a(n)=sum(k=0, floor(log(n)/log(2)), (1bittest(n, k))*floor(n/2^(k+1)))
(PARI) a(n)=b=binary(n); sum(k=1, #b, (!b[k])*sum(i=1, k1, b[i]*2^(k1i)))
(PARI) a(n)=if(n<1, 0, if(n%2, a(n\2), a(n/2)+n/2))
(Scheme, with memoizing definecmacro from Antti Karttunen's IntSeqlibrary)
(definec (A233931 n) (cond ((zero? n) n) ((even? n) (+ (A233931 (/ n 2)) (/ n 2))) (else (A233931 (/ ( n 1) 2)))))
;; Antti Karttunen, Dec 21 2013


CROSSREFS

Sequence in context: A174233 A079530 A020815 * A280725 A243328 A243332
Adjacent sequences: A233928 A233929 A233930 * A233932 A233933 A233934


KEYWORD

nonn


AUTHOR

Ralf Stephan, Dec 18 2013


STATUS

approved



