To solve this problem, you'll have to open it on the computer

Two's Power

Math
easy
Score: 20

Given an integer n , return 1(true) if it is a power of two. Otherwise, return 0(false) .

An integer x is said to be in power of two if and only if there exists an integer i such that 2i == x.

Input Format

First Parameter -Number n

Output Format

Return the number (0 or 1).

Try doing it in both recursive and iterative method

Example 1

Input: 22
Output: 0
Explanation: 22 is not power of 2.

Example 2

Input: n=1
Output: 1
Explanation: 2 to power 0 is 1

Example 3

Input: n= 64
Output: 1
Explanation: 2 to power 6 is 64

Constraints:

  • -231 <= n <= 231-1 - 1
Submit code to see the your result here