#K45692. Happy Number Checker
Happy Number Checker
Happy Number Checker
Given an integer n, determine if it is a Happy Number.
A number is called a happy number if the process of repeatedly replacing it by the sum of squares of its digits eventually leads to 1. More formally, starting with a positive integer \(n\), replace the number with the sum of the squares of its digits, i.e., \[ n \to \sum_{d \in D(n)} d^2, \] where \(D(n)\) denotes the digits of \(n\). If this process results in 1, then the number is happy. Otherwise, it falls into a cycle that does not include 1.
Your task is to read an integer from standard input and output True
if it is a happy number and False
otherwise.
inputFormat
The input consists of a single line containing one integer \(n\), where \(1 \le n \le 10^9\).
outputFormat
Output a single line: True
if the number is a happy number, otherwise False
.
19
True
</p>