-
-
Save utsukushiihime/aace7597324d2d728f43932cdb20d918 to your computer and use it in GitHub Desktop.
powerOfTwo JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const powerOfTwo = (num) => { | |
let pot = Math.pow(2, Math.ceil(Math.log2(num))) - num; | |
if (pot === 0) { | |
return "true"; | |
} else { | |
return "false"; | |
} | |
}; | |
console.log(powerOfTwo(4)); | |
console.log(powerOfTwo(124)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment