Is (a/b)/c equal to a/(b*c) for integer division?

Write $a=qb+r$, with $0 \le r \lt b$, so that $a \div b=q$.

Then write $q=sc+t$, with $0 \le t \lt c$, so that $(a \div b) \div c=s$.

We now have $a=b(sc+t)+r=bcs+bt+r$. As $$\begin{aligned} bt+r &\le b(c-1)+(b-1) \\ &=bc-b+b-1 \\ &=bc-1, \end{aligned}$$ we have $a \div (bc)=s$.


It's slightly easier to do the other way than Ross.

Let $q,r$ be integers such that $a = b·c·q+r$ and $0 \le r < b·c$. Then $r \div b \le r / b < c$.

Then $( a \div b ) \div c = ( c·q + ( r \div b ) ) \div c = q + ( r \div b ) \div c = q = a \div ( b·c )$.

(We simply twice used the easy fact that $(d·x+y) \div d = x + y \div d$ for integers $x,y,d$ with $d > 0$.)


Another way to think about this is, say you have $N$ candies that you want to distribute among $a * b$ kids. What is the maximum number of candies a kid can get, given that you distribute the candies equally.

The answer is $\Big\lfloor\frac{N}{a*b}\Big\rfloor$

Note that you can divide the $a * b$ kids into $a$ classes. Since each student gets an equal number of candies, each class also gets an equal number of candies, which is $\le \left\lfloor\frac{N}{a}\right\rfloor$. Now for each class, you distribute these many candies among $b$ kids, so each kid gets

$$\left\lfloor\frac{\left\lfloor\frac{N}{a}\right\rfloor}{b}\right\rfloor$$

Hence,

$$\left\lfloor\frac{\left\lfloor\frac{N}{a}\right\rfloor}{b}\right\rfloor = \left\lfloor\frac{N}{a*b}\right\rfloor$$


I didn't prove that we can give $\Big\lfloor\frac{N}{a}\Big\rfloor$ candies to each class and still ensure that each student will get the optimal number of candies. This can be proven easily as well. Let's say each class gets $Y$ candies in the optimal solution. Then, we have:

$$ Y * a \le N \implies Y \le \frac{N}{a} $$

Hence we can give each class $\left\lfloor\frac{N}{a}\right\rfloor$ candies for optimal distribution.

Note that each class can also reject some candies.