Exists an explicit formula to calculate the minimum $n$ for some $x$ such that $\frac{x}{2^n}\in[0,0.5)+\Bbb Z$?

140 Views Asked by At

For any $x \in \Bbb R$ I want to know if exist an explicit formula that evade recursion to calculate the minimum n such that

$$\frac{x}{2^n}\in[0,0.5)+\Bbb Z$$

where $[0,0.5)+\Bbb Z$ is an uncountable union of equivalent classes that belong to the quotient group $\Bbb R/\Bbb Z$. We can try to symbolize the same, with some abuse of notation, as

$$0\le\frac{x}{2^n}<0.5\pmod 1$$

for $n\in \Bbb N_{\ge 0}$. What I want is the minimum $n$ where the fractional part of $x$ is less than $0.5$. Notice that if $x$ is an integer then $n=0$.

1

There are 1 best solutions below

2
On

(I'm also assuming $n$ should be a positive integer.) To solve this problem, simply write the integer $\lfloor x/10\rfloor$ in binary. Then $n$ is given by the position of the rightmost $0$ in that binary expansion. For example, if $\lfloor x/10\rfloor = 101100111$ in binary, then $n=4$, since the number ends in $0111$.