Created
April 25, 2020 06:26
-
-
Save computer-tutor/0270a963729651933bfbdbb810507b43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_sq_digits(n): | |
ans=0 | |
for i in str(n): | |
ans+=int(i)*int(i) | |
return ans | |
def is_happy(n): | |
if len(str(n))==1: | |
if n==1: | |
return 'It is a Happy Number' | |
else: | |
return 'It is not a happy number' | |
else: | |
n=sum_sq_digits(n) | |
return is_happy(n) | |
print(is_happy(12)) | |
print(is_happy(28)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment