Given an integer n, return True if it is a power of two: 1, 2, 4, 8, 16, 32, 64, ...
Recursive approach:
🧠 Bit trick: A power of 2 in binary has exactly one '1' bit: n & (n-1) == 0. But let's practice the recursive approach first!
is_power_of_two(1)
True
is_power_of_two(16)
True
is_power_of_two(6)
False
is_power_of_two(64)
True
is_power_of_two(0)
False