problem
solution1:
class Solution { public: int addDigits(int num) { int sum = 0; int n = num; while(n/10) { sum = n/10 + n%10; n = sum; } return n; } };
solution2:
class Solution { public: int addDigits(int num) { return 1+((num-1)%9); } };
参考
2. Digital_root;
完