This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A303065 #24 May 21 2025 12:21:44 %S A303065 0,0,0,0,1,1,2,0,0,1,2,1,3,2,3,0,0,2,3,3,4,4,5,1,5,6,7,2,8,3,4,0,0,1, %T A303065 2,4,3,5,6,4,4,7,8,5,9,6,7,1,5,10,11,8,12,9,10,2,13,11,12,3,13,4,5,0, %U A303065 0,1,2,6,3,7,8,9,4,9,10,10,11,11,12,5,5,12,13 %N A303065 Number of numbers < n whose binary representation has the same difference between the numbers of 0's and 1's as n does. %C A303065 First occurrence of k, k=0,1,2,...: 0, 4, 6, 12, 20, 22, 25, 26, 28, 44, 49, ..., . - _Robert G. Wilson v_, Feb 08 2018 %C A303065 Ordinal transform of A037861, minus one. - _David Radcliffe_, May 21 2025 %H A303065 Alois P. Heinz, <a href="/A303065/b303065.txt">Table of n, a(n) for n = 0..32768</a> %F A303065 a(n) = 0 iff n belongs to A097110. - _Rémy Sigrist_, May 16 2018 %e A303065 There are two numbers below 6 with number of 1's in the binary representation minus number of 0's equal to 1, namely 1 and 5, therefore a(6)=2. %e A303065 There are 3 numbers below 12 with number of 1's in the binary representation minus number of 0's equal to 0, namely 2, 9, 10, therefore a(12)=3. %p A303065 b:= n-> `if`(n=0, 1, add(1-2*i, i=Bits[Split](n))): %p A303065 p:= proc() -1 end: %p A303065 a:= proc(n) option remember; local t; %p A303065 t:= b(n); p(t):= p(t)+1 %p A303065 end: %p A303065 seq(a(n), n=0..82); # _Alois P. Heinz_, May 21 2025 %t A303065 d[n_] := DigitCount[n, 2, 1] - DigitCount[n, 2, 0]; f[n_] := Block[{fd = d[n], c = k = 0}, While[k < n, If[d@ k == fd, c++]; k++]; c]; Array[f, 83, 0] (* _Robert G. Wilson v_, Feb 08 2018 *) %o A303065 (Python) %o A303065 d=[0]*200 %o A303065 for n in range(1024): %o A303065 b = bin(n)[2:] %o A303065 c0 = b.count('0') %o A303065 c1 = len(b) - c0 %o A303065 diff = c0 - c1 %o A303065 print(d[100+diff], end=', ') %o A303065 d[100+diff] += 1 %o A303065 (Python) %o A303065 from collections import Counter %o A303065 from itertools import count, islice %o A303065 def a303065_gen(): %o A303065 counter = Counter() %o A303065 for n in count(): %o A303065 bitstring = format(n, 'b') %o A303065 diff = bitstring.count('1') - bitstring.count('0') %o A303065 yield counter[diff] %o A303065 counter[diff] += 1 %o A303065 a303065_list = list(islice(a303065_gen(), 83)) # _David Radcliffe_, May 21 2025 %Y A303065 Cf. A037861, A097110. %K A303065 nonn,look,base %O A303065 0,7 %A A303065 _Alex Ratushnyak_, Apr 17 2018 %E A303065 Offset corrected by _David Radcliffe_, May 21 2025