✅ C++ | Easy to understand
\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        if(s.size()<=1) return s;\n        while(s.size()>k){\n            string tmp;\n   
```\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        if(s.size()<=1) return s;\n        while(s.size()>k){\n            string tmp;\n            int num=0;\n            for(int i=0;i<s.size();i++){\n                if(i && i%k==0){\n                    tmp+=to_string(num);\n                    num=0;\n                }\n                num+=s[i]-\'0\';\n            }\n            tmp+=to_string(num);\n            s=tmp;\n        }\n        return s;\n    }\n};\n```
['String', 'C']