import math def isHappy(n: int) -> bool: if n == 1: return True while n != 1: n = str(n) a = 0 for i in n: i = int(i) a = i * i + a if a < 10 and a > 1 and a != 7: return False n = a return True print(isHappy(2))