0
$\begingroup$

I know how to calculate possible combinations of binary by the rule (2^n) where n is the number of digits , but how to calculate the number of possible binary combinations with specific count of 1,for example: the number of combinations when digits n = 8 ,and 1 count c = 1 is 8 different combinations as follows :

00000001,00000010,00000100,00001000,00010000,00100000,01000000,10000000

can someone help me find the general formula for this ?

$\endgroup$
1
$\begingroup$

The number you are after is the binomial coefficient $$\binom{n}{c}=\frac{n!}{c!(n-c)!}$$ where $n!=1\times2\times3\times\cdots\times n$ is the factorial of $n$.

$\endgroup$
  • $\begingroup$ oh ! how did I miss that thanks ! $\endgroup$ – user2548447 Jun 8 '17 at 4:25
0
$\begingroup$

Just to be sure, you're asking for a formula for the number of ways to take $n$ possible bits and set $k$ of them to 1? Then the answer is the binomial coefficient, or "choose function", ${n \choose k} = \frac{n!}{k!(n-k)!}$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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