快乐的数字

def happy(n):
try:
if n==1:
print("True")
else:
new=str(n)
sum=0
for c in new:
sum+=int(c)**2
return happy(sum)
except Exception as e:
print ("False")
n=eval(input("请输入一个数字:"))
happy(n)

 

posted @ 2021-09-13 21:05  tan45  阅读(105)  评论(0)    收藏  举报