C++ | 0ms
\nclass Solution {\nprivate:\n    string ans;\npublic:\n    string convertToBase7(int num) {\n        if(!num) return "0";\n        convertToBase7(num/7);\n    
```\nclass Solution {\nprivate:\n    string ans;\npublic:\n    string convertToBase7(int num) {\n        if(!num) return "0";\n        convertToBase7(num/7);\n        ans += (abs(num)%7) + \'0\';\n        return num < 0 ? \'-\' + ans : ans;\n    }\n};\n```
['Recursion']