Skip to content

Commit c2a66ba

Browse files
authored
Create 3370-smallest-number-with-all-set-bits.js
1 parent 76d4d56 commit c2a66ba

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
var smallestNumber = function(n) {
6+
let x = n
7+
while ((x & (x + 1)) !== 0) {
8+
x += 1
9+
}
10+
return x
11+
};

0 commit comments

Comments
 (0)