258.Add Digits


  • 0
    Y

    class Solution {
    public int addDigits(int num) {
    int x=num;

        while(x>=10){
    int sum=0;
        while(x>0){           
            sum+=x%10;
            x/=10;
        }
        x=sum;
        }
        return x;
    }
    

    }


Log in to reply
 

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