OFFSET
0,3
REFERENCES
D. E. Knuth, Art of Computer Programming, Sorting and Searching, Addison-Wesley, 1973, Section 5.2.2, ex. 14,15.
LINKS
J.-P. Allouche and J. Shallit, The ring of k-regular sequences, Theoretical Computer Sci., 98 (1992), 163-197, ex. 29.
FORMULA
a(0)=0, a(2n)=a(n)+floor(log_2(2n)), a(2n+1)=a(n)+1.
PROG
a(n)=if(n<1, 0, if(n%2==0, a(n/2)+floor(log(n)/log(2)), a((n-1)/2)+1))
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ralf Stephan, May 05 2003
STATUS
approved