class Solution: def foo(self, num): if len(str(num)) == 1: return num return self.foo(sum([int(x) for x in str(num)])) def addDigits(self, num: int) -> int: return self.foo(num)