Suppose you have 3 positive (non-zero) integers $n,x,y$. Is the following statement true?
$$ \left\lfloor\frac{n y}{x}\right\rfloor = y\left\lfloor\frac{n}{x}\right\rfloor+\left\lfloor\frac{y\left(n\bmod x\right)}{x}\right\rfloor $$
Throwing a large amount of numbers at it, it seems to hold, but I'm not able to prove it.
For reference, I'm trying to implement an algorithm which will involve multiplying two integers (which might overflow), then performing an integer division. I'm trying to break the multiplication up into two smaller multiplications.
Write $n = ax + b$ where $b = (n \mod x)$, i.e. $a$ and $b$ are nonnegative integers with $b < n$, and $\lfloor \dfrac{n}{x} \rfloor = a$. Then $$\dfrac{ny}{x} = ay + \dfrac{by}{x}$$ which is your equation.