# Maximum 2 apples

There are 10 types of fruits, of them 1 type is apples. You have to pick 4 of fruits, but max 2 apples. How many ways are there for you to pick fruits?

-

Hint:

In how many ways can you pick the fruits without apples?

In how many ways can you pick them with 1 apple?

In how many ways can you pick them with 2 apples?

What's the sum of those?

-

Let $x_1$ be the number of apples that you choose, and let $x_2,x_3,\dots,x_{10}$ be the numbers of the other nine types of fruit that you choose. The answer to your question is the number of solutions in non-negative integers of the equation

$$x_1+x_2+x_3+\ldots+x_{10}=4$$

subject to the condition that $x_1\le 2$.

Without that extra condition limiting the value of $x_1$, this is a standard stars-and-bars problem, and the answer is

$$\binom{4+10-1}4=\binom{13}4=715\;.$$

(The reasoning behind this formula is explained reasonably well in the linked article.)

However, we have to subtract from this the solutions that have $x_1>2$. If we choose at least $3$ apples, there are $10$ ways to choose the fourth piece of fruit, so there are just $10$ of these unacceptable choices, and the final answer is $715-10=705$.

-