Remainder is less than divisor

65 Views Asked by At

I'm reading a book and it says the equation $$ a \bmod n = a - n \left\lfloor\frac{a}{n}\right\rfloor$$ follows that $$ 0 \leq a \bmod n \lt n. $$

I understand that the remainder is less than divisor, but I can't understand how the author got it from the first equation. Could someone, please, explain it to me?

2

There are 2 best solutions below

1
On BEST ANSWER

As $\lfloor x\rfloor \le x<\lfloor x\rfloor +1$, we have $$ 0\le \frac an-\left\lfloor \frac an\right\rfloor <1$$ and after multiplication with $n$ the claim.

1
On

Since we have that $$\frac{a}n-1\lt\left\lfloor\frac{a}n\right\rfloor\le\frac{a}n$$ Then we can bound the RHS by $$a-n\left(\frac{a}n\right)\le a-n\left\lfloor\frac{a}n\right\rfloor\lt a-n\left(\frac{a}n-1\right)$$ $$0\le a-n\left\lfloor\frac{a}n\right\rfloor\lt n$$