100 Beats Solution 🔥|| Java 🎯
Approachres * 2 + 1 upto n gives the answerComplexity
Time complexity:O(Log(N))

Space complexity:O(1)
Code
# Approach
res * 2 + 1 upto n gives the answer 
<!-- Describe your approach to solving the problem. -->

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

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
![7865b3eb-6d8d-42fe-9c51-188ad4821476_1733115321.1447082.png](https://assets.leetcode.com/users/images/e812dee3-e02d-41ce-abc8-1faaed3e4feb_1742628549.6887143.png)

# Code
```java []
class Solution {
    public int smallestNumber(int n) {
        int res=1;
        while(res<n){
            res=res*2+1;
        }
        return res;
    }
}
```
['Math', 'Java']