Total possible ways to arrange 40 identical balls in 3 different boxes How many ways are there to arrange 40 identical balls in 3 boxes, such that there is at least 1 ball in each box and the number of balls $n$ in a box is not a multiple of 10.
I already know how to arrange them, without considering that they cannot be a multiple of 10, which is 2 out of 39.
I first thought of 'just' subtracting possibilities when $n$ is a multiple of 10, but that did not get me far. Can someone help me with the thought process when considering $n$ cannot be a multiple of 10? 
 A: *

*How many ways are there to distribute 40 balls among 3 boxes?


$$41+40+39+...+1 = \frac{41\cdot 42}{2}=861$$


*How many ways are there such that box $1$ has a multiple of 10 balls?


$$41+31+21+11+1=105$$


*How many ways are there such that box $1$ and box $2$ have a multiple of 10 balls?


$$5+4+3+2+1=15$$


*How many ways are there such that all boxes have a multiple of 10 balls?


Of course also $15$, as if two boxes have numbers divisible by $10$ then so does the third.
Finally, by the Inclusion-Exclusion Principle, in total there are $$\binom{3}{0}\cdot 861-\binom{3}{1}\cdot 105+\binom{3}{2}\cdot 15-\binom{3}{3}\cdot 15 = 576$$
A: Ways of distributing 40 identical balls to 3 different boxes with at least one ball in each box, 
by Theorem 1 of stars and bars = ${n-1\choose k-1}={40-1\choose 3-1}= 741$
Ways of distributing with at least 1 box having 10,20 or 30 balls 
= ${3\choose 1}[{29\choose 1}+{19\choose1}+{9\choose1}] = 171$
Ways of distributing with at least 2 boxes (which implies all 3 boxes) having balls in 10-10-20 pattern is just $3$,
so applying inclusion-exclusion, we get $741 - 171 + {3\choose2}\cdot3 -{3\choose3}\cdot 3 = 576$
