Skip to content

Commit

Permalink
write function to check if a number is a power of two in python
Browse files Browse the repository at this point in the history
  • Loading branch information
justanindieguy committed Jan 30, 2023
1 parent d9246ed commit 1ed6687
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Bit-manipulationTechniques/TwoPower/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def is_power_of_two(n: int):
if (n & (n - 1)) == 0:
print("Power of two")
else:
print("Not a power of two")


def main():
n = 16
is_power_of_two(n)


if __name__ == "__main__":
main()

0 comments on commit 1ed6687

Please sign in to comment.