We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Complexity Quiz - Example 2

Consider the following code. It calculates the number of times a given number can be divided by 2 before becoming less than or equal to 1.

def naive_log2(x: int) -> int:
    count = 0
    while x > 1:
        x /= 2
        count += 1
    return count