Is Power of Two

EasyMathBit Manipulation

Description

Given an integer n, return true if it is a power of two, and false otherwise.

Examples

Input:n = 16
Output:true
Explanation:

16 can be written as two raised to a whole-number power.

Input:n = 6
Output:false
Explanation:

6 cannot be written as two raised to a whole-number power.

Input:n = 1
Output:true
Explanation:

1 can be written as two raised to a whole-number power.

Constraints

  • -10⁹ ≤ n ≤ 10⁹

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.