Given an integer, write a function to determine if it is a power of two.
1 2 3 4 5 6 7 8 9 10 11 12
| * @param {number} n * @return {boolean} */ function isPowerOfTwo(n) { if (n%2 != 0 && n != 1) return false; else if(n < 2 && n != 1) return false; else if(n == 2) return true; else if(n == 1) return true; else return isPowerOfTwo(n/2); }
|