Find the number of solutions $x_1+x_2+\dots+x_n=r$ where each variable is either $0$ or $1$.

67 Views Asked by At

Find the number of solutions $x_1+x_2+\dots+x_n=r$ where each variable is either $0$ or $1$.

Is this just ${n \choose r}$? Since there are basically $n$ spots to fill with a $0$ or a $1$. We can choose $r$ $1$'s to fill $r$ spots and then the remaining spots we can place the $0$'s in one way. Thus $n \choose r$. I made several examples and this seems to make sense. Any solutions or hints are greatly appreciated.

2

There are 2 best solutions below

0
On

Yes, that's correct. You need exactly the number of $r$-subsets possible out of a set of $n$ distinct items, which is the definition of the binomial coefficient.

0
On

You have the generating-functions tag, so here's such an approach. Because each $x_i$ can be either $0$ or $1$, the generating function is $$\prod_{i=1}^n (1+z) = (1+z)^n = \sum_{r=0}^n \binom{n}{r} z^r,$$ and the coefficient of $z^r$ is indeed $\binom{n}{r}$.