I was trying to formulate some problem. I want to find a relation between a floor and ceiling function. Suppose the Property 1 satisfies that it has $\lfloor \frac{n}{2} \rfloor$ number of $X$. Then the Property 2 satisfies that it has $k = \lceil \frac{d}{2} \rceil$ where $d = \lfloor \frac{n}{2} \rfloor$. I tried to put $k = \lceil \frac{n}{4} \rceil$ but it is contradicting for some values of $n$. Like if I take $n = 9$, then

$d = \lfloor \frac{9}{2} \rfloor$ $\Rightarrow d = 4$ and thus $k = 2$.

But if I take $k = \lceil \frac{n}{4} \rceil$ then $k = \lceil \frac{9}{4} \rceil$ $\Rightarrow k = 3$

which contradicts. Is there any way to find the relation between $n$ and $k$ directly. Kindly help. My data is given below for different values of $n$.

enter image description here


2 Answers 2


Starting from $n=0$ you have

$$d=0,0,1,1,2,2,3,3,4,4,5,5,6,6,\cdots$$ $$k=0,0,1,1,1,1,2,2,2,2,3,3,3,3,\cdots$$

In the last row, you see that the length of the runs is $4$, but the first run has only two elements.




$$d=\left\lfloor\frac n2\right\rfloor\equiv n=2d+d'$$ where $d'=0,1$.

$$k=\left\lceil\frac d2\right\rceil\equiv d=2k-k'$$ where $k'=0,1$.


$$n=4k-2k'+d'=4k+k''$$ where $k''=-2,-1,0,1$.

By shifting,

$$n+2=4k+k'''$$ where $k'''=0,1,2,3$ and


  • $\begingroup$ I have added an image. I hope that is useful. $\endgroup$
    – monalisa
    Commented May 19, 2016 at 6:32
  • 1
    $\begingroup$ @monalisa: hem, I had already written it together with the solution. $\endgroup$
    – user65203
    Commented May 19, 2016 at 6:32

Yves Daoust's way is probably easiest but, just in case, here's a more systematic way of solving it.

\begin{align*} k &= \left \lceil \frac{d}{2} \right \rceil \\ &= \left \lfloor \frac{d+1}{2} \right \rfloor \\ &= \left\lfloor \frac{\lfloor n/2\rfloor + 1}{2} \right\rfloor \\ &= \left\lfloor \frac{n/2 + 1}{2} \right\rfloor \\ &= \left\lfloor \frac{n + 2}{4} \right\rfloor. \end{align*} In the first step I used the identity $$\left\lceil \frac{j}{m} \right\rceil =\left\lfloor \frac{j+m-1}{m} \right\rfloor$$ which holds for all integers $j, m$ with positive $m$. For the third step, it turns out that $$\left\lfloor\frac{\lfloor x \rfloor + j}{m}\right\rfloor = \left\lfloor\frac{x + j}{m}\right\rfloor$$ also holds for all integers $j, m$ with positive $m$, for all real $x$. The same holds for ceilings, but we cannot remove floors from inside ceilings or vice versa, which is why the first step was necessary.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .