Number of steps for a binary search Given an input of a positive integer, output the number of steps it takes to
find the input via a binary search starting at 1.

We are simulating a binary search for the integer that was given as input, in
which the simulated searcher can repeatedly guess an integer and be told
whether it is too high, too low, or correct. The strategy for finding the
integer is as follows:


Let n be the integer given as input that we are trying to find.
Start with a guess of 1. (For every guess, increment the number of steps
(regardless of whether it was correct or not), and immediately stop and
output the total number of steps if the guess was correct.)
Double the guess repeatedly until the guess is greater than n (the target
number). (Or if it is correct, but that's already covered by our
correct-guess rule mentioned above.)
Now, set an upper bound of the first power of 2 that's greater than n (i.e.
the number that was just guessed), and set a lower bound of the power of 2
directly below it.
Repeatedly guess the average (rounded down) of the upper bound and the lower
bound. If it is too high, set it as the upper bound. If it is too low, set it
as the lower bound. This procedure is guaranteed to eventually result in a
correct guess.


Here's an example, for the input of n=21:

1 -&gt; 2 -&gt; 4 -&gt; 8 -&gt; 16 -&gt; 32 -&gt; 24 -&gt; 20 -&gt; 22 -&gt; 21
\__________________________/
   repeated doubling      \________________________/
                             repeated averaging


Since this is code-golf, the shortest code in bytes will win.

Here are all outputs from n=1 to n=100:

1
2
4
3
6
5
6
4
8
7
8
6
8
7
8
5
10
9
10
8
10
9
10
7
10
9
10
8
10
9
10
6
12
11
12
10
12
11
12
9
12
11
12
10
12
11
12
8
12
11
12
10
12
11
12
9
12
11
12
10
12
11
12
7
14
13
14
12
14
13
14
11
14
13
14
12
14
13
14
10
14
13
14
12
14
13
14
11
14
13
14
12
14
13
14
9
14
13
14
12


And here are some larger test cases:

1234 -&gt; 21
1337 -&gt; 22
3808 -&gt; 19
12345 -&gt; 28
32768 -&gt; 16
32769 -&gt; 32
50000 -&gt; 28
Japt, 13 12 bytes
Oh my gosh I was beating both Jelly and Pyth for a time :D
¢a1 ªJ +1+¢l

Test it online!
Here's the strategy I use: let x be the input integer, and let b be x's binary representation. The correct output is 1 + the length of b + the last index of a 1 in b, minus 1 if this index is 0.