OFFSET
0,5
COMMENTS
A recursive sequence that seems to be related to the ruler function.
It seems that a(2n) = a(2n+1) = A080277(n). - Emeric Deutsch, Mar 31 2008
It appears that if the binary expansion of n is n = Sum b_i*2^i (b_i=0 or 1), then a(n) = Sum i*b_i*2^(i-1). - Marc LeBrun, Sep 07 2015
The observations in the preceding two comments (by Emeric Deutsch and Marc LeBrun) follow from the formulas in A333979. - Pontus von Brömssen, Sep 06 2020
This sequence is a variant of the arithmetic derivative (A003415) based on powers of two instead of primes, because the relation a(m*n) = m*a(n) + n*a(m) holds. If we define the polynomial P(2) = bit0*2^0 + bit1*2^1 + bit2*2^2 + ... = n, and P'(2) is the derivative of P(2), then we will observe P'(2) = a(n). - Thomas Scheuerle, Aug 02 2022
FORMULA
a(n) = A333979(n,2). - Pontus von Brömssen, Sep 06 2020
MAPLE
a:=proc(n) if n=0 then 0 else floor((1/2)*n)+2*a(floor((1/2)*n)) end if end proc: seq(a(n), n=0..60); # Emeric Deutsch, Mar 31 2008
MATHEMATICA
a = {0}; Do[AppendTo[a, Floor[n/2] + 2*a[[Floor[n/2] + 1]]], {n, 1, 100}]; a (* Stefan Steinerberger, Mar 24 2008 *)
Table[Sum[2^(k-1)*Floor[n*2^-k], {k, 1, Log[2, n]}], {n, 0, 100}] (* Federico Provvedi, Aug 17 2013 *)
PROG
(PARI) a(n) = fromdigits(Vec(Pol(binary(n))'), 2); \\ Kevin Ryde, Apr 29 2021
(Python)
def A136013(n): return sum(map(lambda x:(x[0]+1)*(1<<x[0]), filter(lambda x:x[1]=='1', enumerate(bin(n)[-2:1:-1])))) # Chai Wah Wu, Jul 06 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jack Preston (jpreston(AT)earthlink.net), Mar 20 2008
EXTENSIONS
More terms from Stefan Steinerberger and Emeric Deutsch, Mar 24 2008
Spelling corrected by Jason G. Wurtzel, Aug 30 2010
STATUS
approved