Happy Number



Happy Number The process for determining a happy or unhappy number is as follows. Take a positive integer and replace the number with the sum of the squares of the digits. Repeat the process until it either repeats a specific pattern ( unhappy number) or ends in 1.

Example with 313 :

313 = 32 + 12 + 32= 9 + 1 + 9 = 19

19 = 12 + 92 = 1 + 81 = 82

82 = 82 + 22 = 64 + 4 = 68

68 = 62 + 82 = 36 + 64 = 100

100 = 12 + 02 + 02= 1 + 0 + 0 = 1

12 = 1 = HAPPY :)