1 = 0b1 -> 1 5 = 0b101 -> 3 10 = 0b1010 -> 4 100 = 0b1100100 -> 7 1000 = 0b1111101000 -> 10 …
How can I get the bit length of an int
def bitcounter(n): return math.floor(math.log(n,2)) + 1
EDIT fixed so that it works with 1