# How is this exactly equal to $N_1+N_2+\dots+N_r$?

There are $N$ boxes, each containing at most $r$ balls. If the number of boxes containing at least $i$ balls is $N_i$ for $i=1,2,\dots,r,$ then the total number of balls contained in these $N$ boxes is exactly equal to $N_1+N_2+\dots+N_r.$

How is that exactly equal to $N_1+N_2+\dots+N_r$? I can't understand why statement containing at least and at most turn to give this exact answer!

I tested for $N=4$ and $r=3$. Suppose that box 1 has 3 balls, box 2 has 2 balls, box 3 has 1 ball and box 4 has 3 balls. So, $N_1=4,N_2=3,N_3=2$ and the conclusion holds!

• How many times have you counted each of the boxes containing exactly $r$ balls? – Arthur Apr 5 '14 at 8:27
• I have shown my try. – Silent Apr 5 '14 at 8:28
• I know, and that's appreciated. I'm trying to hint you toward why this works. So, how many of the $N_i$ terms contain in them the boxes with exactly $r$ balls? – Arthur Apr 5 '14 at 8:31
• All the $N_i$s. – Silent Apr 5 '14 at 8:33

Note that the number of boxes that contains exactly $j$ balls is $N_j-N_{j+1}$. Then, the total number of balls is $$\sum_{j=1}^r j(N_j-N_{j+1})=\sum_{j=1}^{r+1}N_j(j-(j-1))=\sum_{j=1}^rN_j$$ since $N_{r+1}=0$.

• ☺♥ Thank you so much! – Silent Apr 5 '14 at 8:42
• How did you get $\sum_{j=1}^{r+1}N_j(j-(j-1))$? – Silent Apr 5 '14 at 9:02
• Take for example $r=3$ : $N_1-N_2+2N_2-2N_3+3N_3-3N_4=$ $=N_1(1-0)+N_2(2-1)+N_3(3-2)+N_4(4-3)$. Note that since $N_4=0$ you can multiplicate it by whatever you want. – ajotatxe Apr 5 '14 at 9:11

If a box contains $b$ balls, then it is counted into $N_1, N_2, \ldots, N_b$. For example a box with $3$ balls has "at least three balls", so it is counted in $N_3$, but it also has "at least two balls" and "at least one balls", so it also counted in $N_2$ and $N_1$ respectively. So you count each box as many times as is the number of balls the box contains.

• ☺♥ Thank you so much! – Silent Apr 5 '14 at 8:41

It is given that $$N_1$$ is the number of boxes with at least $$1$$ ball and $$N_2$$ is the number of boxes with at least $$2$$ balls, then we can certainly conclude that the total number of boxes with exactly $$1$$ ball is $$N_1-N_2$$. Now ball contribution to the total number of balls by these $$N_1-N_2$$ boxes is equal to $$1\times(N_1-N_2).$$

Again, we have that $$N_2$$ is the number of boxes with at least $$2$$ balls and $$N_3$$ is the number of boxes with at least $$3$$ balls, then we can certainly conclude that the total number of boxes with exactly $$2$$ balls is $$N_2-N_3$$. Now ball contribution to the total number of balls by these $$N_2-N_3$$ boxes is equal to $$2\times(N_2-N_3).$$

Going on like this we can conclude that the total number of boxes having exactly $$n$$ balls is equal to $$N_{n}-N_{n+1}$$, $$\forall$$ $$1\le n\le r-1$$. Therefore ball contribution to the total number of balls by these $$N_{n}-N_{n+1}$$ boxes is equal to $$n\times(N_{n}-N_{n+1})$$.

Now the total number of boxes having at least $$r$$ balls is $$N_r$$. But, since we are provided with the constrain that each of the $$N$$ boxes contains at most $$r$$ balls, we can conclude that the total number of boxes having exactly $$r$$ balls is $$N_r$$, and ball contribution by these $$N_r$$ boxes is $$r\times N_r$$.

Therefore, total number of balls contained in these $$N$$ boxes is $$\sum_{i=1}^{r-1}(N_i-N_{i+1})i+rN_r=N_1+N_2+N_3+...+N_r.$$