Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 430 Bytes

258. Add Digits.md

File metadata and controls

23 lines (19 loc) · 430 Bytes

258. Add Digits

Add Digits - LeetCode

class Solution {
    public int addDigits(int num) {
        while (num >= 10)
        {
            int sum = 0;
            while (num != 0) {
                int digits = num % 10;
                sum += digits;
                num /= 10;
            }
            num = sum;
        }
        
        return num;
    }
}