[Math] How many ways can you pick out 15 candies total to throw unordered into a bag and take home

combinationscombinatorics

A store sells 8 kinds of candy. How many ways can you pick out 15 candies total to throw unordered into a bag and take home.

here 15 candies..
so we choose 8 from out of 15 is ..=$^{15}C_8$ is i am right

Best Answer

Call the various types of candy Type 1, Type 2, and so on up to Type 8. Let $x_1$ be the number of Type 1 candies we get, $x_2$ the number of Type 2 candies we get, and so on up to $x_8$.

Then the $x_i$ are non-negative integers, and $x_1+x_2+\cdots +x_8=15$.

Conversely, if $x_1,x_2,\dots, x_8$ are non-negative integers with the sum of the $x_i=15$, we can produce a candy selection by choosing $x_1$ of Type 1, $x_2$ of Type 2, and so on up to Type 8.

So the number of different candy selections is the number of solutions of $$x_1+x_2+\cdots +x_8=15\tag{1}$$ in non-negative integers.

By Stars and Bars (please see Wikipedia) Equation (1) has $\binom{15+8-1}{15}$ solutions, or equivalently $\binom{15+8-1}{8-1}$ solutions.