#K60967. Happy Number Checker
Happy Number Checker
Happy Number Checker
In this problem, you are given a positive integer (n) and your task is to determine whether it is a happy number. A number is called a happy number if, by repeatedly replacing the number with the sum of the squares of its digits, the process eventually reaches 1. Otherwise, the number will loop endlessly in a cycle that does not include 1.
For example, starting with (n = 19), the process goes as follows: (19 \to 1^2 + 9^2 = 82), (82 \to 8^2 + 2^2 = 68), (68 \to 6^2 + 8^2 = 100), (100 \to 1^2 + 0^2 + 0^2 = 1). Thus, 19 is a happy number. Write a program which reads an integer from standard input and prints "YES" if it is a happy number, and "NO" otherwise.
inputFormat
The input is provided via standard input (stdin) and consists of a single integer (n) where (1 \leq n \leq 10^9).
outputFormat
Output the result to standard output (stdout). Print "YES" if the integer is a happy number, otherwise print "NO".## sample
19
YES