Created
January 9, 2016 11:24
-
-
Save arkilis/52f2cc55a4900dfd7394 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
class Solution(object): | |
def isHappy(self, n): | |
""" | |
:type n: int | |
:rtype: bool | |
Be careful, this is NOT correct code, teaching purpose only | |
""" | |
def rec_happy(n): | |
sz= str(n) | |
sum= 0 | |
for e in sz: | |
sum+=int(e)**2 | |
if(sum==1): | |
return True | |
else: | |
return rec_happy(sum) | |
return rec_happy(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment