Assume we have set $A$ with $n$ elements and we want to choose $k$ items with the maximal number of repetitions $r$.
If $r = 1$ then repetitions are not allowed. Then this number can be computed as $n \choose k$.
I also know that the number of all allowed combinations with any number of repetitions equals $n+k-1 \choose k$
But how can I compute the number of combinations with at most $r$ repetitions, and some item chosen exactly $r$ times?
Example: take $A = \{a,b,c\}$ and $k = 3$:
- $r=1$: {(a,b,c)} 1 choice
- $r=2$: {(a,a,b),(a,a,c),(b,b,a),(b,b,c),(c,c,a),(c,c,b)} 6 choices
- $r=3$: {(a,a,a),(b,b,b),(c,c,c)} 3 choices