Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #16 Mar 03 2016 02:53:52
%S 1,1,1,1,2,1,1,1,3,2,1,1,2,1,1,1,4,3,2,2,2,1,1,1,3,2,1,1,2,1,1,1,5,4,
%T 3,3,4,2,2,2,3,2,1,1,2,1,1,1,4,3,2,2,2,1,1,1,3,2,1,1,2,1,1,1,6,5,4,4,
%U 6,3,3,3,6,4,2,2,4,2,2,2,4,3,2,2,2,1,1
%N Product of lengths of runs of 0-bits in binary representation of n, or 1 if no nonleading zeros present.
%H Antti Karttunen, <a href="/A227350/b227350.txt">Table of n, a(n) for n = 0..8192</a>
%F A167489(n) = a(n) * A227349(n).
%F A227193(n) = A227349(n) - a(n).
%F A227355(n) = a(A003714(n)).
%F A003714 gives the only terms k for which a(k) = A167489(k).
%e a(0) = 1, regardless whether one considers the binary representation of zero to have one zero or no digits at all, because also the empty product is 1. Similarly for any numbers of form (2^k)-1, where no nonleading 0-bits occur, the result of an empty product is always 1.
%e a(8) = 3, as 8 is "1000" in binary, and there is one run of three 0-bits present.
%e a(68) = 6, 68 is "1000100" in binary, there are one run of three 0-bits and one run of two 0-bits, thus 2*3 = 6.
%p a:= proc(n) local i, m, r; m, r:= n, 1;
%p while m>0 do
%p for i from 0 while irem(m, 2, 'h')=0 do m:=h od;
%p while irem(m, 2, 'h')=1 do m:=h od;
%p r:= r*max(i, 1)
%p od; r
%p end:
%p seq(a(n), n=0..100); # _Alois P. Heinz_, Jul 11 2013
%t a[n_] := Times @@ Length /@ Select[Split @ IntegerDigits[n, 2], #[[1]] == 0 &]; Array[a, 100, 0] (* _Jean-François Alcover_, Mar 03 2016 *)
%o (Scheme)
%o (define (A227350 n) (apply * (bisect (reverse (binexp->runcount1list n)) (modulo n 2))))
%o (define (bisect lista parity) (let loop ((lista lista) (i 0) (z (list))) (cond ((null? lista) (reverse! z)) ((eq? i parity) (loop (cdr lista) (modulo (1+ i) 2) (cons (car lista) z))) (else (loop (cdr lista) (modulo (1+ i) 2) z)))))
%o (define (binexp->runcount1list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2)) (loop (floor->exact (/ n 2)) (cons count rc) 1 (modulo n 2)))))))
%Y Cf. A023416 (sum of lengths of runs of 0-bits), A167489, A227349, A227355, A227193.
%K nonn,base,look
%O 0,5
%A _Antti Karttunen_, Jul 08 2013