Example 1:
Input
1000
Output:
945
Example 2:
Input:
2000
Output:
945
1575
For example if n = 44, we get
Step 1: 4^2 + 4^2= 32
Step 2: 3^2 + 2^2= 13
Step 3: 1^2 + 3^2= 10
Step 4: 1^2 + 0^2 = 1 - terminates the process and the output
is: YES, 4
Write a program that reads one integer and outputs the following: if the number is happy, it outputs YES and the number of steps it took to get from the input to 1 (including the step that resulted in 1), otherwise, the program outputs NO and the number of steps it took to get to the beginning of the cycle (including the step that resulted in 4)
For example, if n = 43, we get
Step 1: 4^2 + 3^2 = 25
Step 2: 2^2 +5^2 = 29
Step 3: 2^2 + 9^2 = 85
Step 4: 8^2 + 5^2 = 89
Step 5: 8^2 + 9^2 = 145
Step 6: 1^2 +4^2 +5^2 = 42
Step 7: 4^2 +2^2 = 20
Step 8: 22 +02 = 4
The output NO, 8