We'll say that for a positive whole number n
, the squareSum
of n
is the sum of the squares of the digits of n
. So if n
is 1406
, then squareSum(n)
is 1^(2) + 4^(2) + 0^(2) + 6^(2)
= 1 + 16 + 0 + 36
= 53
.
We further say that the k^(th)-squareSum
of n
is squareSum(squareSum(...(squareSum(n))))
, where squareSum
is composed k
-many times. For example, the 3rd-squareSum of 1406
is squareSum(squareSum(squareSum(1406)))
= squareSum(squareSum(53))
(as we know from above) = squareSum(5^(2) + 3^(2))
= squareSum(25 + 9)
= squareSum(34)
= 3^(2) + 4^(2)
= 9 + 16
= 25
.
Definition: A number n
is happy if for some positive integer m
, the m^(th)-squareSum
of n
is equal to 1
.