#coding=utf-8
# 解题思路: 查找表 20190302 找工作期间
class Solution(object):
def isHappy(self, n):
"""
:type n: int
:rtype: bool
"""
temp_res = []
while True:
n = self.getAdd(n)
if n == 1:
return True
else:
if n not in temp_res:
temp_res.append(n)
else:
return False
def getAdd(self,n):
res = 0
while n != 0:
g = n %10
res += g ** 2
n = int(n / 10)
return res