%I #22 May 07 2021 08:11:45
%S 0,0,0,2,0,3,3,3,0,4,4,4,4,4,6,7,0,5,5,5,5,5,7,8,5,5,8,9,8,9,11,11,0,
%T 6,6,6,6,6,8,9,6,6,9,10,9,10,12,12,6,6,10,11,10,11,13,13,10,11,14,14,
%U 14,14,14,17,0,7,7,7,7,7,9,10,7,7,10,11,10,11,13,13,7,7,11,12,11,12,14,14,11,12,15,15,15,15,15,18,7,7,12,13,12,13,15,15,12
%N a(n) = A029931(n) - A280700(n).
%H Antti Karttunen, <a href="/A283981/b283981.txt">Table of n, a(n) for n = 0..8192</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F a(n) = A029931(n) - A280700(n).
%F a(n) = A283982(n) + A124757(n).
%t Table[#.Reverse@ Range@ Length@ # &@ IntegerDigits[n, 2] - DigitCount[2 n - DigitCount[2 n, 2, 1], 2, 1], {n, 0, 120}] (* _Michael De Vlieger_, Mar 20 2017, after _Jean-François Alcover_ at A029931 *)
%o (Scheme) (define (A283981 n) (- (A029931 n) (A280700 n)))
%o (PARI)
%o a(n) = if(n<1, 0, a(n - 2^logint(n,2)) + logint(n,2) + 1);
%o b(n) = if(n<1, 0, b(n\2) + n%2);
%o A(n) = b(2*n - b(2*n));
%o for(n=0, 150, print1(a(n) - A(n),", ")) \\ _Indranil Ghosh_, Mar 21 2017
%o (Python)
%o import math
%o def L(n): return int(math.floor(math.log(n,2)))
%o def a(n): return 0 if n<1 else a(n - 2**L(n)) + L(n) + 1
%o def A(n): return bin(2*n - bin(2*n)[2:].count("1"))[2:].count("1")
%o print([a(n) - A(n) for n in range(151)]) # _Indranil Ghosh_, Mar 21 2017
%Y Cf. A005187, A029931, A124757, A280700, A283475, A283477, A283982.
%K nonn,base,look
%O 0,4
%A _Antti Karttunen_, Mar 19 2017