For any positive integer , define as the sum of the squares of the digits of (in base ten). For example, . Find the greatest integer such that there exists a positive integer with .
Solution
The greatest is .
One can easily check that
so that . It remains to check .
We first prove that has at most digits. Suppose on the contrary that where . For any , we have
(To prove for , we check the base case and the inductive step .) Using this, we can easily prove that for any . Thus, it is impossible that .
Similarly, if , then for , we have
If , then for , we have
Thus, we must have .
Note that is also the image of some term in the cycle. Let for some . If , then the only possibility is . But then we have
which enters the cycle with largest term , and so it never goes back to . Therefore, we must have . This completes the proof.
Want a route through all this instead of an archive? The track
puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.