Counting number of integer solutions to $a_1 + a_2 + a_3 + \ldots = n$ where all $a$'s must be in certain range

76 Views Asked by At

For a given $(n,m,k)$..

Using values in the range $(0..k)$, how many different $m$-combos exist which sum to n?

ex. for $(n,m,k)$ = $(3,3,2)$, there are 7 possible combinations. For $(5,4,2)$ there are 16 if I didn't miss any writing them all down.

I've been trying to approach the problem as counting the number of integer solutions to $a_1 + a_2 + a_3 + .. = n$ and using the binomial formula, but I'm not sure how the constraint that $\forall a \in (0..k)$ changes the math.


Edit

A comment suggested inclusion-exclusion so I thought about it and think I'm on the right track.

For $(n,m,k) = (5,4,2)$, the total solutions to $a_1+a_2+a_3+a_4 = 5$ (without considering k) would be ${n+m-1 \choose m-1} == $ 56

There are 4 ways to sum up to 5 using at least 1 factor > k=2
$5 = (5||4+1||3+2||3+1+1)^{\star}$ zeroes omitted from each set of 4 terms

The total ways of permuting each of these 4-combos is $\frac{4!}{3!}+3\left(\frac{4!}{2!}\right) = $ 40
Thus, $56 - 40 =$ the desired 16 4-combos.

I've been trying to figure out a formula and have discovered that the Fibonacci sequence is of some relevance. The number of ways to sum up to $n$ using at least 1 term $> k$ I have found is..

$$\sum_{i=0}^{n-k} F_i$$ However, I can't seem to figure out the number of repeated elements formulaically in each of the ways of summing up to $n$ as in the starred$^{\star}$ eq. above.

This might have gotten too contrived, but anybody have any hints or ideas?