Let's say I have numbers each taken in a set $A$ of $n$ consecutive naturals, I ask myself : how can I found what are all the unique multisets, which could be created with $k$ elements of this set $A$?
For example I've got $A=[1,2,\dots,499]$. If I wanted to create unique multiset of 3 elements, I would search all the multisets $\{a,b,c\}$ such as $a\leq b\leq c$ and then have all the unique multisets. As such for each elements $a$ there is $499-(a-1)=500-a$ possibilities for $b$ and $500-b$ possibilities for $c$. Unfortunately I'm stumped here and can't find the number of possible combination, as I didn't do any maths for years. I know that I should have some kind of product, but I don't know how to find the product anymore.
So first, I would like to know if I am right in my original assumption, or if I am looking in the wrong direction. Second I would like to approach that as if I were doing an homework, as I would like to understand the logic behind it: What would be the formula to give the numbers of multisets of $k$ elements from a set $A$ of $n$ consecutive naturals?
P.S. I'm totally new to math.SE, as such, I'm not sure I tagged the post appropriately.
Hint: If $O_i$ is the number of occurrences of $i$ in the multiset, the tuple $(O_1, O_2, \dots, O_n)$ uniquely identifies the multiset. What constraint can you write down with the $O_i$, if the multiset has exactly $k$ elements?
Ok, to elaborate.
The number of multisets of size $k$ is equal to the number of non-negative integral solutions to the equation
$$O_1 + O_2 + \dots + O_n = k$$
Since the stars and bars method was already mentioned, here is a derivation of the formula using a more general approach, which is one of the main building blocks of analytic number theory: Generating Functions.
The number of solutions to the above equation is same as the coefficient of $x^k$ in
$$(1 + x + x^2 + x^3 + \dots )(1+x + x^2 + x^3 + \dots) \dots (1+ x + x^2 + x^3 + \dots) \ \text{repeated} \ n \ \text{times} \ \text{(why?)}$$
The above is same as
$$ \frac{1}{(1-x)^n} = (1-x)^{-n}$$
as $$ (1 + x + x^3 + x^3 + \dots) = \frac{1}{1-x}$$
Now we apply binomial theorem, (which is also valid for negative exponents)
The coefficient of $x^k$ is $$-1^{k}\ \frac{-n(-n-1)(-n-2)\dots(-n-(k-1))}{k!} = \frac{n(n+1)(n+2)\dots(n+k-1)}{k!}$$
$$= \frac{(n-1)!n(n+1)(n+2)\dots(n+k-1)}{(n-1)!k!}= {n+k-1 \choose k} $$