C Solution


  • 0
    F
    int addDigits(int num) {
        int s,d;
        do{
            s=0;
            do{
                d=num%10;
                num/=10;
                s+=d;
            }while(num!=0);
            num=s;
        }while(s/10!=0);
        return s;
    }
    

Log in to reply
 

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