Then `return np.ceil(np.log2(n) + 1)` should do the trick?