programming-examples/python/Misc/Python program to check if a given positive integer is a power of two.py

6 lines
153 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def is_Power_of_two(n):
return n > 0 and (n & (n - 1)) == 0
print(is_Power_of_two(4))
print(is_Power_of_two(36))
print(is_Power_of_two(16))