OFFSET
0,5
COMMENTS
Ratio a(n)/A213709(n) develops as: 1, 0, 0.5, 0.333..., 0.4, 0.333..., 0.471..., 0.400..., 0.426..., 0.449..., 0.480..., 0.494..., 0.502..., 0.501..., 0.497..., 0.489..., 0.479..., 0.469..., 0.461..., 0.455..., 0.453..., 0.454..., 0.458..., 0.464..., 0.469..., 0.475..., 0.480..., 0.484..., 0.488..., 0.492..., 0.496..., 0.499..., 0.502..., 0.503..., 0.505..., 0.505..., 0.505..., 0.505..., 0.505..., 0.504..., 0.504..., 0.503..., 0.503..., 0.502..., 0.502..., 0.502..., 0.503..., 0.503... (See further comments at A218543).
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..47
EXAMPLE
PROG
(Scheme with memoizing definec-macro): (definec (A218542 n) (if (zero? n) 1 (let loop ((i (- (expt 2 (1+ n)) n 2)) (s 0)) (cond ((pow2? (1+ i)) (+ s (- 1 (modulo i 2)))) (else (loop (- i (A000120 i)) (+ s (- 1 (modulo i 2)))))))))
(define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1))))) ;; A004198 is bitwise AND
;; Or with a summing-function add:
(define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Nov 02 2012
EXTENSIONS
More terms from Antti Karttunen, Jun 05 2013
STATUS
approved