Simple C solution


  • 6
    L
    int addDigits(int num) {
        int x;
        if(num==0){
            return 0;
        }
        else
        {
            x=num%9;
            if(x==0)
                return 9;
            else
                 return x;
        }
    }

Log in to reply
 

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