Number of different possibilities including repeats so in one of my math classes, we're learning about counting and using this operation called "n choose k" $\binom{n}{k}=\frac{n!}{k!(n-k)!}$, however this operation does not account for the possibilities of repeats, and answers with repeating variables.
An analogy would be that you want to buy a pizza with the following conditions:


*
  
*up to 3 toppings on each pizza
  
*7 toppings to choose from


The pizza toppings must be unique—double or triple toppings are not allowed. The arrangement of the toppings on each pizza does not matter; e.g., tomatoes on top of
pepperoni is the same as pepperoni on top of tomatoes.
What is the total number of possibilities for a pizza order in this deal?
And we learned that the answer would be $x=\binom{7}{0} + \binom{7}{1} + \binom{7}{2}+\binom{7}{3}=64$.
However, how would you find how many pizzas you could order with double or triple toppings.  So pretty much using this "choose" function, but allowing for those doubles and triples to come up in the count.  I tried this manually, by writing down all the possibilities and I found that the "choose" did not account for a pretty significant amount of doubles and triples.
Ex: $\binom{7}{3}=35$, and when I drew out all the possibilities for lets say the 3 toppings were A, B, C, D, E, F, G.  I found there to be an extra 49 pizzas which could be accounted for (if there are repeated toppings, like AA, BB etc...).
Another Ex: For $\binom{7}{2}=21$, if we draw the two by two table you can see that the diagonal is the only place where two of the same variables meet, and this "choose" function does not account for them.
So essentially my question is, how do you account for these without doing what I did, by manually drawing out all the tables, and physically finding all the possibilities which can have 2 or 3 repeated values? Like is there a mathematical way of finding this?
And to conclude from what I found then there would be a total of $64+49+7+7=127
$ ways to get a pizza with the 2nd condition.  The extra 7 I added in there is intuitively there can only be 7 pizzas which have the same toppings, like AAA, BBB, CCC, DDD, EEE, FFF, GGG.
 A: So for example, if you want to compute the number of ways to choose $3$ toppings out of $7$ not necessarily distinct, and the order in which they are put on the pizza does not matter, here is how you could do it:


*

*Choose three indices $i_1<i_2<i_3$ from $\{1,2,...,9\}$, since $7+3-1=9$.

*Map $i_2\mapsto i_2-1$ and $i_3\mapsto i_3-2$.


Then $i_1\leq i_2\leq i_3$ are chosen from $\{1,2,...,7\}$. This gives you
$$
\binom{9}{3}=84
$$
instead of
$$
\binom73=35
$$
thus accounting for the remaining $84-35=49$ other possibilities where some toppings are equal.
A: There is indeed a way of counting "combinations with repitition" using a technique we call Stars and Bars.
The short explanation is that given $n$ identical balls and $r$ distinguishable buckets there are $\binom{n+r-1}{r-1}$ different ways to arrange the balls.  Equivalently $\binom{n+r-1}{n}$ different ways.
This is a common enough calculation that some people like to use a special notation for it: $\left(\!\!\binom{n}{r}\!\!\right)$
The way the formula comes about is by imagining a sequence of stars and bars, and the location of the stars corresponds to which bucket the balls are in.  You will need as many stars as balls and one fewer number of bars as number of buckets.
In your specific problem, you may think of the flavors as being the buckets and the number of toppings used as the balls.  If you have two balls in the pepperoni bucket and one ball in the onion bucket that corresponds to having a pizza with pepperoni twice and onion once.

We have between 0 and 3 toppings to place.  With $n$ as the number of toppings to choose and $r$ as the number of choices available, we have then a total count of:
$\left(\!\!\binom{0}{7}\!\!\right)+\left(\!\!\binom{1}{7}\!\!\right)+\left(\!\!\binom{2}{7}\!\!\right)+\left(\!\!\binom{3}{7}\!\!\right)$
$=\binom{6}{0}+\binom{7}{1}+\binom{8}{2}+\binom{9}{3}=120$
