BackeasyRecursion

Check Power of Two Solution

Problem Statement

Given an integer n, return true if it is a power of two recursively. An integer n is a power of two if there exists an integer x such that n == 2^x.

Example 1
Input
16
Output
true

Explanation: 16 is 2^4.

Example 2
Input
3
Output
false

Explanation: 3 is not a power of two.

Constraints

  • -2^31 <= n <= 2^31 - 1
Live Compiler
Sign InSign Up
Loading...
Test Cases & Output
Click "Run" to execute