#K80132. Determining a Happy Number
Determining a Happy Number
Determining a Happy Number
Given a positive integer \( n \), determine if it is a Happy Number. A happy number is defined by the following process:
- Replace the number by the sum of the squares of its digits, i.e. compute \( s(n)=\sum_{i=1}^{k} d_i^2 \), where \( d_i \) represents each digit of \( n \).
- Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1.
If the process results in 1 within 100 iterations, then \( n \) is considered a Happy Number. Otherwise, if a cycle is detected or 100 iterations are reached without arriving at 1, \( n \) is Not Happy.
Examples:
- For \( n=19 \), the sequence eventually reaches 1, so the answer is "Happy".
- For \( n=4 \), the process does not reach 1 in 100 steps and falls into a cycle, so it is "Not Happy".
inputFormat
The input consists of a single integer \( n \) provided via standard input.
outputFormat
Output a single line to standard output containing either "Happy" if \( n \) is a happy number, or "Not Happy" otherwise.
## sample19
Happy
</p>