OFFSET
0,3
LINKS
A. Karttunen, Table of n, a(n) for n = 0..2055
J. Vaillé, Une Bijection Explicative de Plusieurs Propriétés Remarquables des Ponts, European J. Combin. 18 (1997), no. 1, 117-124.
PROG
(MIT Scheme:) (define (A125986 n) (let ((z (reduce append! '() (reverse! (descending-list->bin-lists (binexp->A071158-list (A014486 n)))))) (tl (A057515 n))) (A080300 (/ (+ (<< (- (<< 1 tl) 1) (+ (length z) 1)) (binlist->n z)) 2))))
(define (descending-list->bin-lists rl) (let loop ((z (list)) (m 1)) (let ((sl (map (lambda (n) (- n m)) (keep-matching-items rl (lambda (n) (or (= n m) (= n (+ 1 m)))))))) (cond ((null? sl) z) (else (loop (cons sl z) (+ m 1)))))))
(define (binlist->n binlist) (let loop ((s 0) (bl binlist)) (if (null? bl) s (loop (+ s s (car bl)) (cdr bl)))))
(define (binexp->A071158-list n) (let loop ((n n) (lista (list)) (h 1)) (cond ((zero? n) lista) ((odd? n) (loop (/ (- n 1) 2) lista (- h 1))) (else (loop (/ n 2) (cons h lista) (1+ h))))))
(define (>> n i) (if (zero? i) n (>> (floor->exact (/ n 2)) (- i 1))))
(define (<< n i) (if (<= i 0) (>> n (- i)) (<< (+ n n) (- i 1))))
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Jan 02 2007
STATUS
approved