2
$\begingroup$

Given an integer $N ≥ 0$ and an integer $K ≥ 0$, how many tuples $(n_1,\ldots,n_k)$ are there such that $n_i ≥0$ and $\Sigma n_i = N$? In other words, how many way can you "partition" $N$ into $K$ sets such that the sum of the sets adds up to $N$.

For example, $n = 5$, $k =2$ gives 6 tuples: $(5,0) , (4,1) \ldots (0,5)$.

I've come up with this recursive definition:

$P(n,k) =$ # of tuples $(n_1,..,n_k)$ such that $n_i ≥ 0$ and $\Sigma n_i = N$
$P(n,k) = \Sigma_{i=0}^n{P(i,k-1)}$
$P(0,k)=1 $
$P(n,1)=1$

A suggested answer below is that this problem is the Stirling #'s of 2nd kind but I am not sure how to reduce this problem to it. See my response below.

My question is if there's a closed form solution for $P(n,k)$?

  • 0
    @BrianM.Scott: Okay, yes, probably too much work.2012-05-16

1 Answers 1

2

This is a standard stars-and-bars problem; the answer is that $p(n,k)=\binom{n+k-1}{k-1}=\binom{n+k-1}n=\frac{(n+k-1)!}{(k-1)!\,n!}\;.$ The explanation in the Wikipedia article cited above is pretty clear. What you’re counting are called compositions of $n$ into $k$ parts; you’ll find more information on them here. (A search of this site for stars and bars will turn up many variations on this type of problem, some with quite detailed answers, but the Wikipedia stars-and-bars article is your best starting point.)