Leetcode #258 Add Digits

来源:互联网 发布:福建网络继续教育学院 编辑:程序博客网 时间:2024/05/22 15:33
class Solution {public:        int addDigits(int num) {        int sum = 0;    while(num > 0)    {    sum += num %10;    num = num /10;    }    if(sum >= 10)    return addDigits(sum);    else return sum;    }};

0 0