OFFSET
0,11
COMMENTS
EXAMPLE
PROG
(Scheme): (define (A209640 n) (if (or (zero? n) (not (member_of_A209641? n))) 0 (let* ((w (/ (binwidth n) 2))) (let loop ((rank 0) (row 1) (u (- w 1)) (n (- n (A053644 n))) (i (/ (A053644 n) 2)) (first_0_found? #f)) (cond ((or (zero? row) (zero? u) (zero? n)) (+ (expt 2 (-1+ w)) rank)) ((> i n) (loop rank (- row 1) u n (/ i 2) #t)) (else (loop (+ rank (if first_0_found? (A007318tr (- (+ row u) 1) (- row 1)) (A007318tr (- w 1) (- row 1)))) (+ row 1) (- u 1) (- n i) (/ i 2) first_0_found?)))))))
(define (binwidth n) (let loop ((n n) (i 0)) (if (zero? n) i (loop (floor->exact (/ n 2)) (1+ i)))))
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Mar 24 2012
STATUS
approved