Floor function proof using division algorithm

580 Views Asked by At

How could I prove that if $n,k\in\mathbb{Z}$ such that $n\geq1$ and $k\geq2$, then

$$\lceil{n/k}\rceil = \lfloor{\frac{n-1}{k}}\rfloor +1$$

I was thinking of using Euclidian algorithm of division but I have a brain fart if you will that I dont know how to conclude.

$\exists q,r\in\mathbb{Z}$ such that $0\leq r<k$ and $n = qk + r \Rightarrow \frac{n}{k} = q + \frac{r}{k}$ where since $0\leq r<k$ then $0\leq\frac{r}{k}<1$

Therefore $q\leq\lceil{n/k}\rceil =\lceil{q + r/k}\rceil\leq q+1 $,

My idea was to express $\lfloor{\frac{n-1}{k}}\rfloor +1$ in the same way and then show that $0\leq \lceil{n/k}\rceil -\lfloor{\frac{n-1}{k}}\rfloor +1\leq 0$ but for some reason I don't know how to do it.

I think I'm either missing some intuition about the floor function or the division algorithm.

1

There are 1 best solutions below

0
On BEST ANSWER

Let $n = qk + r; 0 \le r < k$ by the division algorithm.

$\lceil \frac nq \rceil = $ $q$ if $r = 0;$ or $q+1$ if $r > 0$.

Meanwhile

$n - 1 = qk + (r-1)$

$= (q-1)k + (k + r -1)$

If $r > 0$ then $\lfloor \frac {n-1}k\rfloor = q$

But if $r = 0$ then $(k+r -1) = k-1 < k$ and $\lfloor \frac {n-1}k\rfloor = q - 1$

So $\lfloor \frac {n-1}k\rfloor + 1 = q|q+1$ depending upon whether $r=0$ or $r > 0$.

Which are the same conditions as to whether $\lceil \frac nq \rceil = q|q + 1$.

So whether $r=0$ and $\lceil \frac nq \rceil = \lfloor \frac {n-1}k\rfloor + 1 = q$, or whether $r > 0$ and $\lceil \frac nq \rceil = \lfloor \frac {n-1}k\rfloor + 1 = q+1$,

either way $\lceil \frac nq \rceil =\lfloor \frac {n-1}k\rfloor + 1$.