cp's OEIS Frontend

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.

A090706 Number of numbers having in binary representation the same number of zeros and ones as n has.

This page as a plain text file.
%I A090706 #40 Mar 07 2025 01:31:35
%S A090706 1,1,1,1,1,2,2,1,1,3,3,3,3,3,3,1,1,4,4,6,4,6,6,4,4,6,6,4,6,4,4,1,1,5,
%T A090706 5,10,5,10,10,10,5,10,10,10,10,10,10,5,5,10,10,10,10,10,10,5,10,10,10,
%U A090706 5,10,5,5,1,1,6,6,15,6,15,15,20,6,15,15,20,15,20,20,15,6,15,15,20,15,20
%N A090706 Number of numbers having in binary representation the same number of zeros and ones as n has.
%H A090706 Reinhard Zumkeller, <a href="/A090706/b090706.txt">Table of n, a(n) for n = 0..10000</a>
%H A090706 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Binary.html">Binary</a>
%H A090706 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/DigitCount.html">Digit Count</a>
%H A090706 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A090706 a(n) = binomial(A070939(n)-1, A000120(n)-1).
%F A090706 a(n) = binomial(A070939(n)-1, A023416(n)).
%e A090706 From _Ruud H.G. van Tol_, Apr 17 2014: (Start)
%e A090706 n=25->'11001': a(25) = #{'10011'->19, '10101'->21, '10110'->22, '11001'->25, '11010'->26, '11100'->28} = 6.
%e A090706 n=23->'1_0111' has 5 bits, and the lower 4 bits can be shuffled. There are 1 zero and 3 ones, so the number of combinations is C(4,1) = 4 (the zero can be in 4 positions).
%e A090706 n=31->'1_1111': C(4,4) = 1.
%e A090706 n=33->'1_00001': C(5,1) = 5 (the one can be in 5 positions).
%e A090706 n=35->'1_00011': C(5,2) = 10. (End)
%t A090706 a[n_] := Binomial[Length[b = IntegerDigits[n, 2]]-1, Count[b, 0]]; a[0] = 1; Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Apr 25 2014 *)
%o A090706 (PARI) A090706 = n->binomial(#binary(n)-1,hammingweight(n)-(n>0)) \\ About 20% faster than the alternative "...-1)+!n". - _M. F. Hasler_, Jan 04 2014
%o A090706 (Python)
%o A090706 from math import comb
%o A090706 def A090706(n): return comb(n.bit_length()-1,n.bit_count()-1) if n else 1 # _Chai Wah Wu_, Mar 06 2025
%Y A090706 Cf. A000120, A007088, A007318, A014312, A023416, A070939.
%K A090706 nonn,base
%O A090706 0,6
%A A090706 _Reinhard Zumkeller_, Jan 15 2004
%E A090706 Missing a(0)=1 added and offset adjusted by _Reinhard Zumkeller_, Dec 19 2012