[Java/Python 3] Bit Manipulations.
java\n    private static final List<Integer> table = new ArrayList<>(Arrays.asList(0));\n    public int concatenatedBinary(int n) {\n        if (table.size() <=
```java\n    private static final List<Integer> table = new ArrayList<>(Arrays.asList(0));\n    public int concatenatedBinary(int n) {\n        if (table.size() <= n) {\n            long num = table.get(table.size() - 1);\n            for (int i = table.size(); i <= n; ++i) {\n                num <<= 32 - Integer.numberOfLeadingZeros(i);\n                num |= i;\n                num %= 1_000_000_007;\n                table.add((int)num);\n            }\n        }\n        return table.get(n);\n    }\n```\n```python\n    def concatenatedBinary(self, n: int) -> int:\n        return int(\'\'.join(bin(i)[2 :] for i in range(1, n + 1)), 2) % (10 ** 9 + 7)\n```
[]