C# - Simple O(N) using Binary Length
csharp\npublic int ConcatenatedBinary(int n)\n{\n\tlong result = 0;\n\tint MOD = (int)(1E9) + 7;\n\tint binaryLength = 0;\n\n\tfor (int i = 1; i <= n; i++)\n\t{
```csharp\npublic int ConcatenatedBinary(int n)\n{\n\tlong result = 0;\n\tint MOD = (int)(1E9) + 7;\n\tint binaryLength = 0;\n\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tif ((i & (i - 1)) == 0)\n\t\t{\n\t\t\tbinaryLength++;\n\t\t}\n\n\t\tresult = ((result << binaryLength) + i) % MOD;\n\t}\n\n\treturn (int)(result % MOD); \n}\n```
[]