OFFSET
0,6
COMMENTS
For every one bit in the binary representation of n, add the number represented by the substring left of it.
LINKS
FORMULA
EXAMPLE
27 is 11011 in binary, so we add 1, 110=6, and 1101=13, so a(27)=20.
PROG
(PARI) a(n)=if(n<1, 0, if(n%2, a(n\2)+n\2, a(n/2)))
(PARI) a(n)=sum(k=0, floor(log(n)/log(2)), bittest(n, k)*floor(n/2^(k+1)))
(Scheme, with memoizing definec-macro from Antti Karttunen's IntSeq-library)
(definec (A233905 n) (cond ((zero? n) n) ((even? n) (A233905 (/ n 2))) (else (+ (A233905 (/ (- n 1) 2)) (/ (- n 1) 2)))))
;; Antti Karttunen, Dec 21 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
Ralf Stephan, Dec 17 2013
STATUS
approved