How to get rid of the ceil function

1k Views Asked by At

I have the following expression and I'm wondering how to get rid of the ceil function (if possible at all):

$$ answer = 2n - 4 - \lceil \dfrac{n}{2} \rceil $$

Is there a way to get rid of it such that I end up with a simpler answer?

2

There are 2 best solutions below

2
On BEST ANSWER

$\lceil n/2 \rceil = n/2$ if $n$ is even, $(n+1)/2$ if $n$ is odd. You could write that as $$\frac{2n + 1 - (-1)^n}4$$

0
On

Hint. Consider two cases: when $n$ is odd and when $n$ is even. Then $$\left\lceil \frac{n}{2} \right\rceil = \begin{cases} \frac{n}{2}&\text{if $n$ is even,}\\ \frac{n+1}{2}&\text{if $n$ is odd.} \end{cases}$$