I m doing this
def power_two(n, base = -1):
result = 2 ** base
if result < n:
base += 1
power_two(n, base)
else:
if result == n:
print base
else:
print base - 1
what is the pythonic way to find largest power of two less than X number?
EDIT
example: power_two(100) return only the power
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…