floor function identity

246 Views Asked by At

I would appreciate if somebody could help me with the following problem:

Q: How to proof? $(n,k\in\mathbb{N})$

$$1=\left\lfloor\frac{n}{k}\right\rfloor-\left\lfloor\frac{n-1}{k}\right\rfloor$$

2

There are 2 best solutions below

0
On

You cannot prove what is not true. Plugging in $n<k$ will result in $$\left\lfloor \frac{n}{k} \right\rfloor-\left\lfloor \frac{n-1}{k} \right\rfloor=0$$

1
On

We have $$\frac nk-1<\left\lfloor \frac{n}{k} \right\rfloor\le \frac nk$$ and $$\frac{1-n}k\le-\left\lfloor \frac{n-1}{k} \right\rfloor<\frac{1-n}k+1$$ so adding these inequalities gives $$\frac1k-1<\underbrace{\left\lfloor \frac{n}{k} \right\rfloor-\left\lfloor \frac{n-1}{k} \right\rfloor}_{\in\Bbb Z}<\frac1k+1$$ so $$\left\lfloor \frac{n}{k} \right\rfloor-\left\lfloor \frac{n-1}{k} \right\rfloor\in\{0,1\}$$ Notice that the two values are possible. For example: $k=n=1$ gives the value $1$ and $n=2$ and $k=3$ gives the value $0$.