Xiaohe-LeetCode 258 Add Digit
This is not the best one.
public class Solution {
public int addDigits(int num) {
if(num<10)
return num;
int sum=0;
while(num>=10)
{
sum=sum+num%10;
num=(num-num%10)/10;
}
sum=sum+num;
if(sum<10)
return sum;
else
return addDigits(sum);
}
}