|
|
A277007
|
|
Number of maximal runs of 1-bits (in binary expansion of n) such that the length of run > 1 + the total number of zeros anywhere right of that run.
|
|
5
|
|
|
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,60
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
For n=3, "11" in binary, the only maximal run of 1-bits is of length 2, and 2 > 0+1 (where 0 is the total number of zeros to the right of it), thus a(3) = 1.
For n=59, "111011" in binary, both the length of run "11" at the least significant end exceeds the limit (see case n=3 above), and also the length of run "111" exceeds 1 + the total number of 0's to the right of it, thus a(59) = 1+1 = 2.
For n=60, "111100" in binary, the length of only run of 1's is 4, and 4 > 2+1, thus a(60) = 1.
For n=118, "1110110" in binary, the length of rightmost run of 1-bits is 2, but that is not > 1+1 (one more than the number of 0-bits right to it). Also, the length of the leftmost run of 1-bits is 3, but that is not > 1+2, thus a(118) = 0.
For n=246, "11110110" in binary, the rightmost run of 1-bits does not contribute, but the leftmost run of 1-bits has now length 4, which is more than 1+2 (where 2 is the total number of 0-bits right of it), thus a(246) = 1.
|
|
PROG
|
(Scheme)
;; Standalone iterative implementation:
(define (A277007 n) (let loop ((e 0) (n n) (z 0) (r 0)) (cond ((zero? n) (+ e (if (> r (+ 1 z)) 1 0))) ((even? n) (loop (+ e (if (> r (+ 1 z)) 1 0)) (/ n 2) (+ 1 z) 0)) (else (loop e (/ (- n 1) 2) z (+ 1 r))))))
|
|
CROSSREFS
|
Differs from the similar entry A277017 for the first time at n=60, where a(60)=1, while A277017(60)=0.
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|