'''
输入任意数字,求其每个数字之和;
若数字之和大于10,则继续求和;
如66;6+6=12;12>10;1+2=3
输出3
'''
def fun(n):
while n%10!=n or n>10:
result = 0
a = n%10
result += a
n = int(n/10)
result += n
n = result
return result
if __name__ == '__main__':
# i = input("Please input a num:")
#result = fun(int(i))
i = 66
results = fun(i)
print(results)
输入任意数字,求其每个数字之和; 若数字之和大于10,则继续求和; 如66;6+6=12;12>10;1+2=3 输出3
最新推荐文章于 2022-02-19 10:12:55 发布