n=int(input('Enter an integer:'))
m=n
c=1
s=0
while c>0:
s=0
while m>0:
a=m%10
s+=a**2
m=m//10
if s==1:
print('This is a happy number')
break
elif s<10:
break
else:
c=s
m=s
if s!=1:
print('This is not happy number')
n=int(input('Enter an integer:'))
m=n
c=1
s=0
while c>0:
s=0
while m>0:
a=m%10
s+=a**2
m=m//10
if s==1:
print('This is a happy number')
break
elif s<10:
break
else:
c=s
m=s
if s!=1:
print('This is not happy number')
Comments
Post a Comment