class Solution:
    def isHappy(self, n: int) -> bool:

        def calculate(number):

            sum_ = 0

            while number:
                digit = number % 10
                sum_ += (digit * digit)
                number //= 10

            return sum_

        seen_sums = set()

        while True:

            number = calculate(n)

            if number in seen_sums:
                return False

            if number == 1:
                return True

            seen_sums.add(number)
            n = number

036da1b4af567f92d8578e92e977f55330c9977f
<mask token>

class Solution:
    <mask token>

class Solution:

    def isHappy(self, n: int) ->bool:

        def calculate(number):
            sum_ = 0
            while number:
                digit = number % 10
                sum_ += digit * digit
                number //= 10
            return sum_
        seen_sums = set()
        while True:
            number = calculate(n)
            if number in seen_sums:
                return False
            if number == 1:
                return True
            seen_sums.add(number)
            n = number

class Solution:
    def isHappy(self, n: int) -> bool:

        def calculate(number):

            sum_ = 0

            while number:
                digit = number % 10
                sum_ += (digit * digit)
                number //= 10

            return sum_

        seen_sums = set()

        while True:

            number = calculate(n)

            if number in seen_sums:
                return False

            if number == 1:
                return True

            seen_sums.add(number)
            n = number
