Write a Python function to Find Whether a Number is a Power of Two


Topic: Write a Python function to Find Whether a Number is a Power of Two

Solution

def is_power_of_two(n):
    if n <= 0:
        return False
    else:
        return n & (n - 1) == 0
		
		
		



List all Python Programs