Created
July 30, 2018 15:52
-
-
Save sikanrong/bf790b6c25ad5bd24265e51c4bb61698 to your computer and use it in GitHub Desktop.
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
//Smallest power of 2 greater than or equal to n | |
//https://www.geeksforgeeks.org/smallest-power-of-2-greater-than-or-equal-to-n/ | |
var smallestPowerOfTwo = function(x){ | |
var bitPlaces = 0; | |
while(x){ | |
bitPlaces++; | |
x >>= 1; | |
} | |
return 1 << bitPlaces; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment