- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution to the problem statement given below.

**Problem statement **− We are given a number, we need to check that the number is a power of two or not.

We can solve this using two approaches as discussed below.

# power of 2 def find(n): if (n == 0): return False while (n != 1): if (n % 2 != 0): return False n = n // 2 return True # Driver code if(find(98)): print('Yes') else: print('No')

No

# power of 2 def find(x): # if x is 0 or not return (x and (not(x & (x - 1))) ) # Driver code if(find(98)): print('Yes') else: print('No')

No

In this article, we have learned how we can check that the given number is a power of two.

- Related Questions & Answers
- Python Program to find whether a no is the power of two
- C++ Program to find whether a number is the power of two?
- Program to check a number is power of two or not in Python
- Program to find Reordered Power of 2 in Python
- Program to find whether a string is alphanumeric.
- C++ program to find whether there is a path between two cells in matrix
- Program to find out the value of a power of 2 in Python
- 8085 program to find nth power of a number
- How to find power of a number in Python?
- Program to Find Out the Maximum Final Power of a List in Python
- Python program to find Intersection of two lists?
- Bash program to find A to the power B?
- Program to find best team with no conflicts in Python
- Check if bitwise AND of any subset is power of two in Python
- Program to find out the vertical area between two points where no point lies and is the widest in Python

Advertisements