%I #21 Jun 05 2013 12:02:17
%S 1,0,1,1,2,3,8,12,23,44,86,163,308,576,1074,1991,3680,6800,12626,
%T 23644,44751,85567,164941,319694,621671,1211197,2362808,4614173,
%U 9018299,17635055,34486330,67408501,131642673,256795173,500346954,973913365,1894371802,3683559071
%N Number of times when an even number is encountered, when going from 2^(n+1)-1 to (2^n)-1 using the iterative process described in A071542.
%C 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).
%H Antti Karttunen, <a href="/A218542/b218542.txt">Table of n, a(n) for n = 0..47</a>
%F a(n) = Sum_{i=A218600(n) .. (A218600(n+1)-1)} A213728(i).
%F a(n) = A213709(n) - A218543(n).
%e (2^0)-1 (0) is reached from (2^1)-1 (1) with one step by subtracting A000120(1) from 1. Zero is an even number, so a(0)=1.
%e (2^1)-1 (1) is reached from (2^2)-1 (3) with one step by subtracting A000120(3) from 3. One is not an even number, so a(1)=0.
%e (2^2)-1 (3) is reached from (2^3)-1 (7) with two steps by first subtracting A000120(7) from 7 -> 4, and then subtracting A000120(4) from 4 -> 3. Four is an even number, but three is not, so a(2)=1.
%o (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)))))))))
%o (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1))))) ;; A004198 is bitwise AND
%o ;; Or with a summing-function add:
%o (define (A218542v2 n) (add A213728 (A218600 n) (-1+ (A218600 (1+ n)))))
%o (define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
%Y Cf. A219662 (analogous sequence for factorial number system).
%K nonn
%O 0,5
%A _Antti Karttunen_, Nov 02 2012
%E More terms from _Antti Karttunen_, Jun 05 2013