Java - Simple & Easy O(N) solution.
The idea is to add powers of 2 if the last bit is 1.\n\n```\n    public int concatenatedBinary(int n) {\n        long res = 0, mul = 1;\n        int mod = 1_000
The idea is to add powers of 2 if the last bit is 1.\n\n```\n    public int concatenatedBinary(int n) {\n        long res = 0, mul = 1;\n        int mod = 1_000_000_007;\n        for(int i = n; i > 0; --i){\n            int no = i;\n            while(no > 0){\n                if(no % 2 == 1) res = (res + mul) % mod;\n                no >>= 1;\n                mul = (mul<<1) % mod;\n            }\n        }\n        \n        return (int)res;\n    }
[]