2
$\begingroup$

Given $n\in\mathbb{N}_{\gt 0}$ provide a closed formula for

$$ f(n):=\sum_{l=0}^{\lceil\log_2(n)\rceil} \bigg\lceil\frac{n}{2^l}\bigg\rceil $$

If there is $k\in\mathbb{N}$, such that $n=2^k$, we have

$$ f(n)=\sum_{l=0}^{k} 2^{k-l}=2^{k+1}-1 $$

obviously, but what about other numbers?

Another easy observation is:

$$ f(2n+2) = 1 + f(2n+1)\quad{}(n\in\mathbb{N}_{\gt 0}) $$

but I was not able to use that, to provide a closed formula.

This is not homework, it us just an itch I could not scratch for now. If there was a formula for that sum, I could calculate some memory requirement for a function I am implementing more precisely. At the moment, I just overestimate it using $f(n) \le f(2^k)$ if $n \le 2^k$.

$\endgroup$
2
  • 1
    $\begingroup$ I don't think you can get a closed form formula for this, but a better approximation is $2n \le f(n) \le 2n + \lceil \log_2 n \rceil + 1$ $\endgroup$
    – EnEm
    Commented Jun 27 at 13:47
  • 1
    $\begingroup$ Thanks for the nice upper bound. For the lower bound you have a typo, it should be $2n-1$. $\endgroup$
    – typetetris
    Commented Jun 28 at 5:53

0

You must log in to answer this question.

Browse other questions tagged .