[LeetCode] 258. Add Digits
Python
class Solution:
    def addDigits(self, num: int) -> int:
        while len(str(num)) > 1:
                num = sum(list(map(int, list(str(num)))))
        
        return num
class Solution:
    def addDigits(self, num: int) -> int:
        while len(str(num)) > 1:
                num = sum(list(map(int, list(str(num)))))
        
        return num
댓글남기기