Happy / Sad Number Calculation


In recreational mathematics, the "happy numbers" and "sad numbers" are the integers that produce particular sequences when you repeatedly square the number's digits and compute the sum of those squares. Integers that stabilize at 1 are called "happy numbers" and integers that fall into the loop are called "sad numbers”. For the example, Positive Integer = 103
Sum of Digits of 103 = 1² + 0² + 3² = 1 + 0 + 9 = 10
10 = 1² + 0² = 1 + 0 = 1
so 103 is a happy number
Positive Integer =

 

Result =