%I #12 Jun 24 2016 15:35:43
%S 1,2,3,5,4,9,7,6,5,11,12,14,9,10,8,7,6,13,14,16,15,20,18,17,11,12,13,
%T 15,10,11,9,8,7,15,16,18,17,22,20,19,18,24,25,27,22,23,21,20,13,14,15,
%U 17,16,21,19,18,12,13,14,16,11,12,10,9,8,17,18,20,19,24,22,21,20,26
%N a(1)=1, if n=(2^k)+1, a(n) = k+2, otherwise a(n) = 2+A000523(n-1)+a(2+A035327(n-1)).
%C Each n > 1 occurs A025147(n) times in the sequence.
%H Ivan Neretin, <a href="/A096116/b096116.txt">Table of n, a(n) for n = 1..10000</a>
%t a = {1}; Do[AppendTo[a, If[BitAnd[n - 1, n - 2] == 0, Log2[n - 1] + 2, 2 + Floor[Log2[n - 1]] + a[[2 + BitXor[n - 1, 2^Ceiling[Log2[n]] - 1]]]]], {n, 2, 74}]; a (* _Ivan Neretin_, Jun 24 2016 *)
%o (Scheme) (define (A096116 n) (cond ((= 1 n) 1) ((pow2? (- n 1)) (+ 2 (A000523 (- n 1)))) (else (+ 2 (A000523 (- n 1)) (A096116 (+ 2 (A035327 (- n 1))))))))
%o (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))
%o ;; _Antti Karttunen_, Aug 25 2006
%Y Cf. A096111, A050029, A050030, A052330, A096113, A096114, A096115.
%K nonn
%O 1,2
%A _Amarnath Murthy_, Jun 30 2004
%E Edited and extended by _Antti Karttunen_, Aug 25 2006
|