Happy Number

class Solution:
	def isHappy(self, n: int) -> bool:
		cache = set()
		while n:
			if n == 1:
				return True
			elif n in cache:
				return False
			else:
				cache.add(n)
				n = sum([n ** 2 for n in map(int, str(n))])
		return False