Take the 2-minute tour ×

I have $n$ numbers of bits. $\frac{n}{2}$ of those bits must be $1$ and $\frac{n}{2}$ of those bits must be $0$ (meaning $00001111$ or $10101001$). How many different binary numbers can I make?

Is there some formula I can apply so that I can figure out if I have $4$ bits made up of two $1$'s and two $0$'s, and then arrange in such a way that I can make $6$ unique numbers?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

The number $n$ must be even. The string is determined once we choose the places where the $n/2$ $1$'s go. These $n/2$ places can be chosen from the $n$ available in $\dbinom{n}{n/2}$ ways.

Things look nicer if we let $n=2m$. Then the number of strings of the type you want is $\dbinom{2m}{m}$. This is equal to $\dfrac{(2m)!}{(m!)^2}$.

In your special case $n=4$, we have $m=2$, and the number is $\dfrac{4!}{(2!)^2}$.

Since $4!=24$ and $2!=2$, there are $6$ strings of the desired type.

More generally, there are $\dbinom{n}{k}=\dfrac{n!}{k!(n-k)!}$ binary strings of length $n$ that have exactly $k$ $1$'s.

share|improve this answer

Your Answer


