Skip to content

Instantly share code, notes, and snippets.

@arkilis
Created January 9, 2016 11:24
Show Gist options
  • Save arkilis/52f2cc55a4900dfd7394 to your computer and use it in GitHub Desktop.
Save arkilis/52f2cc55a4900dfd7394 to your computer and use it in GitHub Desktop.
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