258. Add Digits

public class Solution {
    public int addDigits(int num) {
        int temp=num;
        while(temp/10!=0)
        {
            int res=temp%10;
            while(temp/10!=0)
            {
                temp/=10;
                res+=temp%10;
            }
            temp=res;
        }
        
        return temp;
    }
}
原文地址:https://www.cnblogs.com/aguai1992/p/5664296.html