Project Euler Problem 171
For a positive integer n, let f(n) be the sum of the squares of the digits (in base 10) of n, e.g.
Solution
Answer: 142989277
Let us compute
$$S=\sum_{\substack{0<n<10^{20}\ f(n)\text{ is a perfect square}}} n$$
where
$$f(n)=\sum (\text{digit})^2.$$
We only need the last nine digits of $S$, i.e.