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.

A227193 Difference of (product of runlengths of 1-bits) and (product of runlengths of 0-bits) in binary representation of n.

This page as a plain text file.
%I A227193 #14 Feb 28 2016 12:12:23
%S A227193 0,0,0,1,-1,0,1,2,-2,-1,0,1,0,1,2,3,-3,-2,-1,0,-1,0,1,2,-1,0,1,3,1,2,
%T A227193 3,4,-4,-3,-2,-1,-3,-1,0,1,-2,-1,0,1,0,1,2,3,-2,-1,0,2,0,1,3,5,0,1,2,
%U A227193 5,2,3,4,5,-5,-4,-3,-2,-5,-2,-1,0,-5,-3,-1,0,-2,0
%N A227193 Difference of (product of runlengths of 1-bits) and (product of runlengths of 0-bits) in binary representation of n.
%C A227193 The sequence seems to consist of palindromic subsequences centered around each (2^k)-1 and 2^k (with end points near the terms of A000975), which is easily explained by symmetric pairing of binary expansion of n and its complement.
%H A227193 Antti Karttunen, <a href="/A227193/b227193.txt">Table of n, a(n) for n = 0..10922</a>
%F A227193 a(n) = A227349(n) - A227350(n).
%p A227193 a:= proc(n) local i, j, m, r, s; m, r, s:= n, 1, 1;
%p A227193       while m>0 do
%p A227193         for i from 0 while irem(m, 2, 'h')=0 do m:=h od;
%p A227193         for j from 0 while irem(m, 2, 'h')=1 do m:=h od;
%p A227193         r, s:= r*j, s*max(i, 1)
%p A227193       od; r-s
%p A227193     end:
%p A227193 seq(a(n), n=0..100);  # _Alois P. Heinz_, Jul 11 2013
%t A227193 a[n_] := With[{s = Split @ IntegerDigits[n, 2]}, Times @@ Length /@ Select[ s, First[#]==1&] - Times @@ Length /@ Select[s , First[#]==0&]]; Table[ a[n], {n, 0, 100}] (* _Jean-François Alcover_, Feb 28 2016 *)
%o A227193 (Scheme) (define (A227193 n) (- (A227349 n) (A227350 n)))
%Y A227193 Cf. A145037, A227190.
%K A227193 sign
%O A227193 0,8
%A A227193 _Antti Karttunen_, Jul 08 2013