人生苦短,我用python
我感覺我這種做法太邪惡了。。。
class Solution:
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
num=str(num)#變成字符串來進行處理
count=0
while len(num)!=1:
for i in num:
count += int(i)
num=str(count)
count=0
return int(num)