Given an array such as follows:
4, 16, 37, 58, 89, 145, 42, 20, 4, 16.
we found that the value of each element is the sum of the squares of all digits of the previous element(16 = 42, 37 = 12 + 62, 58 = 32 + 72 and so on). As you can see, the array is repeated with a cycle of length 8. Now, our questions is: given a starting integer, please output the cycle length.