def isHappy(self, n):
        """
        Start with several simple cases and find the pattern.

        if converge to 1, return True
        if loop, return False
        :param n:
        :rtype: bool
        """
        nxt = 0
        appeared = set()
        while True:
            nxt += (n%10)*(n%10)
            n /= 10
            if n == 0:
                if nxt == 1:
                    return True
                if nxt in appeared:
                    return False

                appeared.add(nxt)
                n = nxt
                nxt = 0
dataset/ETHPy150Open algorhythms/LeetCode/202 Happy Number.py/Solution.isHappy/original