3
$\begingroup$

While doing some Computer Science problems, I found one which I thought could be solvable using combinatorics instead of programming:

Given two positive integers $n$ and $k$, in how many ways do $k$ numbers, all of which are between $0$ and $n$ (inclusive), add up to $n$?

In the problem, order does matter. For example, 0+20 is not equivalent to 20+0. This led me to the following solution:

Assume you do want to create the sum without any of the terms being zero. Then, the problem can be looked at as if you have $n$ rocks, and you want know the number of ways you can place $k-1$ sticks between them, such that no stick may be placed between the same two rocks. This is obviously equal to $\binom{n-1}{k-1}$.

If you then want to count the number of ways you can create the sum with exactly one of the terms being zero. Then the solution is (number of ways to get to $n$ using $k-1$ non-zero terms)*(the number of ways we can choose 1 element among k). Then, when wanting to count the number of ways with exactly $x$ zeroes, the answer is (number of ways to get to n using $k-x$ non-zero terms)*(the number of ways we can choose $x$ elements among $k$).

The solution to the original problem will basically the sum of the above expression, with x ranging between $0$ and $k-1$ (since there needs to be at least 1 non-zero term).

This leads to $\displaystyle\sum_{i=0}^{k-1}\left[ \binom{n-1}{k-i-1}\binom{k}{i}\right]$

I later went on to search on Google if there existed any simpler solution, and found that $\binom{n+k-1}{n}$ worked as well, but without explanation and proof.

Both solutions give the same answer for any positive $n$ and $k$, but I really have trouble understanding why. I've tried to simplify my summation, and proving it inductively, but I have not been successful.

Could somebody help me prove the equality?

$\binom{n+k-1}{n} = \displaystyle\sum_{i=0}^{k-1}\left[ \binom{n-1}{k-i-1}\binom{k}{i}\right]$

$\endgroup$
7
  • 1
    $\begingroup$ Hint: Find instead the number of ways of dividing $n+k$ into $k$ parts, all $\ge 1$. $\endgroup$ Commented Jul 23, 2011 at 14:32
  • $\begingroup$ That was a really nice solution too, and a bit more mathematical I suppose. :-) $\endgroup$ Commented Jul 23, 2011 at 14:53
  • $\begingroup$ Very related... $\endgroup$ Commented Jul 23, 2011 at 14:59
  • $\begingroup$ Your final equation is an example of Vandermonde's identity en.wikipedia.org/wiki/Vandermonde%27s_identity $\endgroup$
    – user940
    Commented Jul 23, 2011 at 15:00
  • $\begingroup$ @Byron - cool, even an algebraic proof there! $\endgroup$ Commented Jul 23, 2011 at 15:07

2 Answers 2

2
$\begingroup$

Taking your rocks and sticks example, your basic question is how many ways are there to place $n$ rocks and $k-1$ sticks in order as each pattern (of the rocks) is one solution to your problem. This is ${n+k-1 \choose n}$.

If $n=1$ then all your discussion of $i$ zero terms will come out at $0$ except when $i=k-1$ and in that case you will have $\left[ \binom{0}{0}\binom{k}{k-1}\right] = k$, so you do not need to distinguish $n=1$ in your expression.

$\endgroup$
1
$\begingroup$

There is no need to break into cases concerning the existence of piles of "0 rocks". A pile of zero rocks can be represented by having two "sticks" between the same two rocks (between those two sticks there are zero rocks!). Indeed, I can represent any number of consecutive piles of zero rocks by having the appropriate number of sticks between the same two rocks.

So, with that in mind, I am really looking to count the number of ways that I can place $k-1$ sticks among $n$ rocks. (By the way, why does this representation still retain the ordering? Try finding sticks and rocks representations of $0 + 20$ and $20 + 0$, and other combinations.) Now, this is equivalent to choosing from $n + k - 1$ objects, exactly $n$ of them to be our "rocks" (leaving the other $k-1$ to be our "sticks"). And there are $\binom{n+k-1}{n}$ ways to do that.

Hope this helps!

$\endgroup$
3
  • $\begingroup$ By the way, your piecewise identity can be written as a single formula! What happens when $n = 1$? In the summation, there is a binomial coefficient with $n-1 = 0$ on the top, which evaluates to $0$ unless the bottom is also $0$ (in which case, $\binom{0}{0} = 1$), which occurs only when $k - i - 1 = 0$, or $i = k-1$. But then the second factor would be $\binom{k}{i} = \binom{k}{k-1} = k$. The sum is exactly equal to $k$ when $n = 1$. $\endgroup$
    – Shaun Ault
    Commented Jul 23, 2011 at 14:48
  • $\begingroup$ Ah, of course! Makes sense now that you say it. Thanks! $\endgroup$ Commented Jul 23, 2011 at 14:49
  • $\begingroup$ Yeah, of course 0 choose 0 = 1. Silly me. $\endgroup$ Commented Jul 23, 2011 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .