Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|improve this question
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|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.