[CPP] [Recursion] Easy to Understand with explanation..
We will be using recursion to solve this question. Assume that we have an answer till n-1 returned by the recursive function. We store this in the temp variable
We will be using recursion to solve this question. Assume that we have an answer till `n-1` returned by the recursive function. We store this in the `temp` variable. \n\nNow, from this `temp`, we need to calculate the final answer for the given `n`.\n\n* Shift the answer returned for `n-1` (stored in `temp`) by the number of bits to represent `n`.\n* Add `n` to that.\n* Return (with mod `1000000007`)\n\n```\n\nclass Solution {\npublic:\n    int mod = 1000000007;\n    unsigned int helper(unsigned int n) \n    { \n       unsigned int count = 0; \n       while (n) \n       { \n            count++; \n            n >>= 1; \n        } \n        return count; \n    } \n    \n    int concatenatedBinary(int n) {\n        if (n == 1){\n            return 1;\n        }\n        \n        long temp = concatenatedBinary(n-1);\n        \n        return ((temp<<helper(n)) + n)%mod;\n    }\n};\n```
[]