Power of
Given an integer, write a function to determine if it is a power of.
https://leetcode.com/problems/power-of-two/
Two points.
The power of the whole number of 2, either after the radical is a whole number (the number is also 2 of the whole power), or divided by 2 after the root is an integer. Continue to recursively judge the result of the radical until it touches 1 or 2.
For example, 1024 (2^10), which is multiplied by two 32 (2^5), 2048 (2^11), is multiplied by two 32 (2^5) and multiplied by 2.
1 /**2 * @param {number} n3 * @return {Boolean}4 */5 varIspoweroftwo =function(n) {6 if(N < 1){7 return false;8}Else if(n = = 2 | | n = = 1){9 return true;Ten}Else{ One varsqrt =math.sqrt (n); A if(sqrt = = =parseint (sqrt)) { - returnispoweroftwo (sqrt); -}Else{ then = N/2; -sqrt =math.sqrt (n); - if(sqrt = = =parseint (sqrt)) { - returnispoweroftwo (sqrt); +}Else{ - return false; + } A } at } -};
[Leetcode] [JavaScript] Power of