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.

A359495 Sum of positions of 1's in binary expansion minus sum of positions of 1's in reversed binary expansion, where positions in a sequence are read starting with 1 from the left.

This page as a plain text file.
%I A359495 #21 Jan 09 2023 12:41:35
%S A359495 0,0,-1,0,-2,0,-2,0,-3,0,-2,1,-4,-1,-3,0,-4,0,-2,2,-4,0,-2,2,-6,-2,-4,
%T A359495 0,-6,-2,-4,0,-5,0,-2,3,-4,1,-1,4,-6,-1,-3,2,-5,0,-2,3,-8,-3,-5,0,-7,
%U A359495 -2,-4,1,-9,-4,-6,-1,-8,-3,-5,0,-6,0,-2,4,-4,2,0,6
%N A359495 Sum of positions of 1's in binary expansion minus sum of positions of 1's in reversed binary expansion, where positions in a sequence are read starting with 1 from the left.
%C A359495 Also the sum of partial sums of reversed binary expansion minus sum of partial sums of binary expansion.
%H A359495 Alois P. Heinz, <a href="/A359495/b359495.txt">Table of n, a(n) for n = 0..16383</a>
%F A359495 a(n) = A029931(n) - A230877(n).
%F A359495 If n = Sum_{i=1..k} q_i * 2^(i-1), then a(n) = Sum_{i=1..k} q_i * (2i-k-1).
%e A359495 The binary expansion of 158 is (1,0,0,1,1,1,1,0), with positions of 1's {1,4,5,6,7} with sum 23, reversed {2,3,4,5,8} with sum 22, so a(158) = 1.
%p A359495 a:= n-> (l-> add(i*(l[-i]-l[i]), i=1..nops(l)))(Bits[Split](n)):
%p A359495 seq(a(n), n=0..127);  # _Alois P. Heinz_, Jan 09 2023
%t A359495 sap[q_]:=Sum[q[[i]]*(2i-Length[q]-1),{i,Length[q]}];
%t A359495 Table[sap[IntegerDigits[n,2]],{n,0,100}]
%o A359495 (Python)
%o A359495 def A359495(n):
%o A359495     k = n.bit_length()-1
%o A359495     return sum((i<<1)-k for i, j in enumerate(bin(n)[2:]) if j=='1') # _Chai Wah Wu_, Jan 09 2023
%Y A359495 Indices of positive terms are A359401.
%Y A359495 Indices of 0's are A359402.
%Y A359495 A030190 gives binary expansion, reverse A030308.
%Y A359495 A070939 counts binary digits.
%Y A359495 A230877 adds up positions of 1's in binary expansion, reverse A029931.
%Y A359495 Cf. A000120, A048793, A053632, A222955, A231204, A291166, A326669, A326672, A326673, A359042, A359043.
%K A359495 sign,look,base
%O A359495 0,5
%A A359495 _Gus Wiseman_, Jan 05 2023