Power of Two Problem Statement

Determine whether a given integer N is a power of two. Return true if it is, otherwise return false.

Explanation

An integer 'N' is considered a power of two if it can be expressed in the form 2^K where 'K' is an integer.

Input

The first line of input contains an integer ‘T’ representing the number of test cases. Then the test cases follow.

The only line of each test case contains an integer 'N'.

Output

For each test case, the only line of output prints whether the integer ‘N’ is a power of 2 or not.

The output for each test case is in a separate line.

Example

Input:
T = 3
2
3
16
Output:
true
false
true

Constraints:

  • 1 <= T <= 100
  • -2^31 <= N <= 2^31 - 1
  • Time Limit: 1sec

Note:

You do not need to print anything; it has already been taken care of. Just implement the given function.

AnswerBot
8d

Check if a given integer is a power of two or not.

  • Check if the given integer is positive.

  • Use bitwise operations to determine if it is a power of two.

  • Return true if it is a power of two, false otherwis...read more

Help your peers!
Add answer anonymously...
Samsung Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter