login
A230877
If n = Sum_{i=0..m} c(i)*2^i, c(i) = 0 or 1, then a(n) = Sum_{i=0..m} (m+1-i)*c(i).
38
0, 1, 1, 3, 1, 4, 3, 6, 1, 5, 4, 8, 3, 7, 6, 10, 1, 6, 5, 10, 4, 9, 8, 13, 3, 8, 7, 12, 6, 11, 10, 15, 1, 7, 6, 12, 5, 11, 10, 16, 4, 10, 9, 15, 8, 14, 13, 19, 3, 9, 8, 14, 7, 13, 12, 18, 6, 12, 11, 17, 10, 16, 15, 21, 1, 8, 7, 14, 6, 13, 12, 19, 5, 12, 11, 18, 10, 17, 16, 23, 4, 11, 10, 17, 9, 16, 15, 22, 8, 15, 14
OFFSET
0,4
COMMENTS
Suggested by Jon Perry's A231204, only now the leading power of 2 gets weight 1.
LINKS
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