# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a301336 Showing 1-1 of 1 %I A301336 #14 Sep 03 2020 15:25:14 %S A301336 -1,0,0,2,1,2,3,6,4,4,4,6,6,8,10,14,11,10,9,10,9,10,11,14,13,14,15,18, %T A301336 19,22,25,30,26,24,22,22,20,20,20,22,20,20,20,22,22,24,26,30,28,28,28, %U A301336 30,30,32,34,38,38,40,42,46,48,52,56,62,57,54,51,50,47,46,45,46,43,42,41,42 %N A301336 a(n) = total number of 1's minus total number of 0's in binary expansions of 0, ..., n. %H A301336 Index entries for sequences related to binary expansion of n %F A301336 G.f.: -1/(1 - x) + (1/(1 - x)^2)*Sum_{k>=0} x^(2^k)*(1 - x^(2^k))/(1 + x^(2^k)). %F A301336 a(n) = A000788(n) - A059015(n). %F A301336 a(n) = A268289(n) - 1. %F A301336 a(A000079(n)) = A000295(n). %e A301336 +---+-----+---+---+---+---+------------+ %e A301336 | n | bin.|1's|sum|0's|sum| a(n) | %e A301336 +---+-----+---+---+---+---+------------+ %e A301336 | 0 | 0 | 0 | 0 | 1 | 1 | 0 - 1 =-1 | %e A301336 | 1 | 1 | 1 | 1 | 0 | 1 | 1 - 1 = 0 | %e A301336 | 2 | 10 | 1 | 2 | 1 | 2 | 2 - 2 = 0 | %e A301336 | 3 | 11 | 2 | 4 | 0 | 2 | 4 - 2 = 2 | %e A301336 | 4 | 100 | 1 | 5 | 2 | 4 | 5 - 4 = 1 | %e A301336 | 5 | 101 | 2 | 7 | 1 | 5 | 7 - 5 = 2 | %e A301336 | 6 | 110 | 2 | 9 | 1 | 6 | 9 - 6 = 3 | %e A301336 +---+-----+---+---+---+---+------------+ %e A301336 bin. - n written in base 2; %e A301336 1's - number of 1's in binary expansion of n; %e A301336 0's - number of 0's in binary expansion of n; %e A301336 sum - total number of 1's (or 0's) in binary expansions of 0, ..., n. %t A301336 Accumulate[DigitCount[Range[0, 75], 2, 1] - DigitCount[Range[0, 75], 2, 0]] %o A301336 (Python) %o A301336 def A301336(n): %o A301336 return sum(2*bin(i).count('1')-len(bin(i))+2 for i in range(n+1)) # _Chai Wah Wu_, Sep 03 2020 %Y A301336 Cf. A000079, A000120, A000295, A000788, A001855, A023416, A037861, A059015, A083652, A145037, A268289, A301896. %K A301336 sign,base %O A301336 0,4 %A A301336 _Ilya Gutkovskiy_, Mar 28 2018 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE