OFFSET
0,4
COMMENTS
Suggested by Jon Perry's A231204, only now the leading power of 2 gets weight 1.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
EXAMPLE
For n=13 we have 1101, so we add 1+2+4, getting a(13)=7.
MAPLE
f:=proc(n) local t1, m, i;
t1:=convert(n, base, 2);
m:=nops(t1)-1;
add((m+1-i)*t1[i+1], i=0..m);
end;
MATHEMATICA
Array[Total[Position[IntegerDigits[#, 2], 1], 2] &, 100, 0] (* Paolo Xausa, Mar 18 2024 *)
PROG
(PARI) a(n) = { my (b=binary(n)); sum(k=1, #b, b[k]*k) } \\ Rémy Sigrist, Jun 25 2021
(Python)
def A230877(n): return sum(i for i, j in enumerate(bin(n)[2:], 1) if j=='1') # Chai Wah Wu, Jan 09 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Nov 08 2013
STATUS
approved