def is_happy(n: int) -> bool:
    """
    Returns True if n is a happy number, False otherwise.
    """
    seen = set()  # to detect cycles
    while n!= 1 and n not in seen:
        seen.add(n)
        n = sum(int(digit) ** 2 for digit in str(n))
    return n == 1