|
|
A227350
|
|
Product of lengths of runs of 0-bits in binary representation of n, or 1 if no nonleading zeros present.
|
|
7
|
|
|
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, 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, 6, 3, 3, 3, 6, 4, 2, 2, 4, 2, 2, 2, 4, 3, 2, 2, 2, 1, 1
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,5
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
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.
a(8) = 3, as 8 is "1000" in binary, and there is one run of three 0-bits present.
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.
|
|
MAPLE
|
a:= proc(n) local i, m, r; m, r:= n, 1;
while m>0 do
for i from 0 while irem(m, 2, 'h')=0 do m:=h od;
while irem(m, 2, 'h')=1 do m:=h od;
r:= r*max(i, 1)
od; r
end:
|
|
MATHEMATICA
|
a[n_] := Times @@ Length /@ Select[Split @ IntegerDigits[n, 2], #[[1]] == 0 &]; Array[a, 100, 0] (* Jean-François Alcover, Mar 03 2016 *)
|
|
PROG
|
(Scheme)
(define (A227350 n) (apply * (bisect (reverse (binexp->runcount1list n)) (modulo n 2))))
(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)))))
(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)))))))
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|