Clip, 22 chars (25 for full program, or 27 for working with zero)
[Fy?!%lyWOO])Fmy#WilyW
Prefix this with F<some value>
to get the answer for that value. Or, for a full program to read from stdin, prefix the code with Fnx
. In a previous answerprevious answer, I golfed a way in Clip to check if something's a power of two. I always return one in that case. Otherwise, increment the result of applying this function (recursively) to 2^(floor(log2(<function parameter>)))
.
To make this work with zero (returning 0), use (28 chars):
[Fy?!yZ]?!%lyWOO])Fmy#WilyW