SP21643 UNHAPPY - Unhappy Numbers

Description

Numbers have feelings too! For any positive integer, take the sum of the squares of each of its digits, and add them together. Take the result, and do it again. A number is Happy if, after repeating this process a finite number of times, the sum is 1. Some happy numbers take more iterations of this process to get to 1 than others, and that would be referred to as its distance from happiness. 1’s distance from happiness is 0. 23’s distance from happiness is 3, since 2 $ ^{2} $ + 3 $ ^{2} $ = 13, 1 $ ^{2} $ + 3 $ ^{2} $ = 10, and 1 $ ^{2} $ + 0 $ ^{2} $ = 1. Numbers are Unhappy if they are infinitely far away from happiness because they get stuck in a loop. Given the lower end and upper end of a range of integers, determine how many Unhappy numbers are in that range (inclusive).

Input Format

N/A

Output Format

N/A