Happy number

Write codeEasy15 min

Your task

A happy number is defined by repeatedly replacing the number with the sum of the squares of its digits; if this process eventually reaches 1 the number is happy, otherwise it loops forever in a cycle that never includes 1. Given a positive integer n (1 <= n <= 2^31 - 1), return True if n is happy and False otherwise. For example 19 to 1+81+1+81 ... -> 1, so 19 is happy.

Examples

is_happy_number(n: int) -> bool
Example 1
Inputis_happy_number(19)
OutputTrue