Easy understand Java Solution


  • 0
    E
    public class Solution {
        public int addDigits(int num) {
            while(num/10 != 0){
                num = addNum(num);
            }
            return num;
        }
        
        private int addNum(int num){
            int res = 0;
            while(num > 0){
                res = res + num % 10;
                num /= 10;
            }
            return res;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.