I'm looking for an algorithm, or better yet formula, that I can use with a piece of paper and a pen to find the greatest power of $2$ less than or equal to a given number.
Suppose I have the number $15285$, what's the easiest way to find out what the greatest integer power of $2$ that is less than or equal to that number without using a calculator? For example, for the number $9$, the maximum power of $2$ is $3$, because $2^4>9\geq 2^3$
The following method is essentially binary expansion, discarding some information along the way.
If $n$ is even, divide by $2$;
If $n$ is odd, subtract $1$ and divide by $2$.
Repeat until you get $1$.
The number of steps is the exponent you are looking for.
Examples
$n=9$: $\to4\to2\to1$, three steps
$n=15$: $\to7\to3\to1$, three steps
$n=16$: $\to8\to4\to2\to1$, four steps $n=15285$: $\to7642\to3821\to1910\to955\to477\to238\to119\to59\to29\to14\to7\to3\to1$, 13 steps
Using a calculator, one can do $\left\lfloor\log_2n\right\rfloor$ (or just take $\log_2n$ and ignore the fractional part).