0 out of 464 challenges solved
Write a Python function `next_power_of_2(n)` that takes an integer `n` as input and returns the smallest power of 2 that is greater than or equal to `n`. #### Examples ```python [main.nopy] next_power_of_2(0) # Output: 1 next_power_of_2(5) # Output: 8 next_power_of_2(17) # Output: 32 ``` #### Constraints - The input `n` will be a non-negative integer.
def next_power_of_2(n): """ Find the smallest power of 2 greater than or equal to n. Args: n (int): A non-negative integer. Returns: int: The smallest power of 2 greater than or equal to n. """ # Implement the function logic here pass