Simple Solution C# | 0 MS
Approach\n Describe your approach to solving the problem. \n\n# Code\ncsharp []\npublic class Solution {\n    public int SmallestNumber(int n) \n    {\n        
# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Code\n```csharp []\npublic class Solution {\n    public int SmallestNumber(int n) \n    {\n        // Count the number of bits\n        int bits = 0;\n        while(n > 0)\n        {\n            n /= 2;\n            bits++;\n        }   \n        int m = 1; \n        int sol = 0;\n        // Calculate the solution\n        for(int i = 1; i <= bits; i ++)\n        {\n            sol += m;\n            m *=2;\n        }\n        return sol;\n    }\n}\n```
['C#']