- 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

# Austin Powers in Python

Suppose we have a number greater than 0, we have to check whether the number is power of two or not.

So, if the input is like 1024, then the output will be True.

To solve this, we will follow these steps −

while n > 1, do

n := n / 2

return true when n is same as 1, otherwise 0

Let us see the following implementation to get better understanding −

## Example

class Solution: def solve(self, n): while n > 1: n /= 2 return n == 1 ob = Solution() print(ob.solve(1024))

## Input

1024

## Output

True

- Related Questions & Answers
- Print powers using Anonymous Function in Python?
- Python Program to Get K initial powers of N
- Powers of two and subsequences in C++
- Powers of 2 to required sum in C++
- Program to check whether number is a sum of powers of three in Python
- Print all prime factors and their powers in C++
- C++ Representation of a Number in Powers of Other
- Return the bases when first array elements are raised to powers from second array in Python
- What are the Output Powers of a Synchronous Motor?
- What are the Input Powers of a Synchronous Motor?
- Count ways to express a number as sum of powers in C++
- Balance pans using given weights that are powers of a number in C++ program
- Find k numbers which are powers of 2 and have sum N in C++
- Print all integers that are sum of powers of two given numbers in C++
- Set the first array elements raised to powers from second array element-wise in Numpy

Advertisements