Optimized simple solution - beats 100%🔥
Complexity
Time complexity: O(1)

Space complexity: O(1)
Code
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int smallestNumber(int n) {
        int powerr = (int) (Math.log(n) / Math.log(2));
        return (int)(Math.pow(2, powerr + 1) - 1);
    }
}
```
['Java']