In the grid, which I described in my last question, every number $x$
has a unique set of $r$ (row number) and $c$ coloumn number.
$x$ is given and $x \in \Bbb N$, we want to get $r$.
This formula lets us calculate $x$ based off the row and coloumn number.
$$2^rc+2^{r-1}=x,\; r \in \Bbb N,\; c \in \Bbb N,\; x \in \Bbb N$$
False part start
solving this equation for $c$ gives us the following equation: $$2^{-r}x-\frac{1}{2}=c$$ If we insert this for c in our original equation we get $$2^r(2^{-r}x-\frac{1}{2})+2^{r-1}=x$$
False part end
The part where I'm struggling is to solve this equation for $r$, so I can insert $x$ and get $r$.
I hope somebody can help me with this...
Edit: the equation I made is stupid. If you were able to follow my thoughts you might got what I'm trying to achieve.
Any help is appreciated :-)
If you know x, divide x by 2 repeatedly until the result is odd. The number of divisions is r-1.
If you know both x and c, then, noting that x = 2^(r-1))(2c + 1), you get r = 1 + log_2((x/(2c+1)).