cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A231204 If n = Sum_{i=0..m} c(i)*2^i, c(i) = 0 or 1, then a(n) = Sum_{i=0..m} (m-i)*c(i).

This page as a plain text file.
%I A231204 #35 Jun 13 2025 22:07:23
%S A231204 0,0,0,1,0,2,1,3,0,3,2,5,1,4,3,6,0,4,3,7,2,6,5,9,1,5,4,8,3,7,6,10,0,5,
%T A231204 4,9,3,8,7,12,2,7,6,11,5,10,9,14,1,6,5,10,4,9,8,13,3,8,7,12,6,11,10,
%U A231204 15,0,6,5,11,4,10,9,15,3,9,8,14,7,13,12,18,2,8,7,13,6,12,11,17,5,11,10,16,9,15,14,20,1,7,6,12
%N A231204 If n = Sum_{i=0..m} c(i)*2^i, c(i) = 0 or 1, then a(n) = Sum_{i=0..m} (m-i)*c(i).
%C A231204 A literal interpretation of the binary numbers.
%C A231204 Sum of the number of digits to the left (exclusive) of each 1 in the binary expansion of n. - _Gus Wiseman_, Jan 09 2023
%H A231204 Rémy Sigrist, <a href="/A231204/b231204.txt">Table of n, a(n) for n = 0..8192</a>
%F A231204 a(n) = A230877(n) - A000120(n). - _Gus Wiseman_, Jan 09 2023
%e A231204 For n=13 we have 1101, so we add 0+1+3=4, getting a(13)=4.
%p A231204 f:=proc(n) local t1,m,i;
%p A231204 t1:=convert(n,base,2);
%p A231204 m:=nops(t1)-1;
%p A231204 add((m-i)*t1[i+1], i=0..m);
%p A231204 end; # _N. J. A. Sloane_, Nov 08 2013
%t A231204 Table[Total[Join@@Position[IntegerDigits[n,2],1]-1],{n,0,100}] (* _Gus Wiseman_, Jan 09 2023 *)
%o A231204 (JavaScript)
%o A231204 for (i=0;i<100;i++) {
%o A231204 s=i.toString(2);
%o A231204 o=0;
%o A231204 sl=s.length;
%o A231204 for (j=0;j<sl;j++) if (s.charAt(j)==1) o+=j;
%o A231204 document.write(o+", ");
%o A231204 }
%o A231204 (PARI) a(n) = { my (b=binary(n)); sum(k=1, #b, b[k]*(k-1)) } \\ _Rémy Sigrist_, Jun 25 2021
%o A231204 (Python)
%o A231204 def A230204(n): return sum(i for i, j in enumerate(bin(n)[2:]) if j=='1') # _Chai Wah Wu_, Jan 09 2023
%Y A231204 Cf. A000120, A029931, A230877, A384868
%Y A231204 Cf. A000523.
%K A231204 nonn,base,easy
%O A231204 0,6
%A A231204 _Jon Perry_, Nov 05 2013
%E A231204 Edited by _N. J. A. Sloane_, Nov 08 2013
%E A231204 Name edited by _Gus Wiseman_, Jan 09 2023