# Combinatorics confusion in formulas

I had this task a while ago; let's say I have 15 balls (5 in three different colors) and 3 identical boxes, in how many different ways can I place the balls in the boxes?

What I thought of was just following the formula for combinations with repetition like:

(n+k-1) choose k


but I got the wrong answer. Instead I was supposed to use something like:

(n+k-1) choose (k-1)


to calculate x1+x2+x3=15 but I don't understand the difference in these approches.

Sorry if I sound unclear somehow but I find it really hard to explain since I'm so confused as well.

• It depends what your $n$ and your $k$ are. If $n$ is balls and $k$ is boxes, then the second one is correct. You're choosing $k\mathord-1$ dividers between the boxes among the balls+dividers ($n+k-1$). – Joffan Dec 20 '16 at 13:30
Imagine that, instead of $k$ boxes, you are putting separators in between the $n$ balls. At each location you can put a ball or a separator. But you don't need $k$ separators - only $k\mathord-1$ - to separate the balls into $k$ classes (=boxes). See stars and bars.