2

For n $\in$ N let $\beta(n)$ denote the number of digits used in the binary representation of n. For example $\beta(1)$ = 1 $\beta(2)$ = 2 $\beta(3)$ = 2 $\beta(4)$ = 3 Find a closed formula for an arbitrary n $\in$ N

where N is the set of natural numbers.

So what I have is the representation of n = 1...12 in binary so, n = 1: $2^0$ n = 2: $2^1$ n = 3: $2^0$ + $2^1$ etc. But the closed form solution isn't apparent

1 Answers1

3

Consider $10011100_2$

$10000000_2 <10011100_2<100000000_2$

$2^7<10011100_2<2^8$

Indeed $10011100_2=156$ has $8$ binary digits

remember that $d=\log_2 n$ is the exponent such that $n=2^d$

thus taking $d=\log_2 156\approx 7.3$, cutting the decimal part with floor function and adding $1$ we have the quantity of digits of the number

Example. $n=2017$

$\left\lfloor \log _2(2017)\right\rfloor +1=11$

$2017=11\,111\,100\,001_2$ has $11$ digits

Raffaele
  • 26,371