Since Project Euler problems are now fair game for questions I have a question of my own. A certain problem* states: > For a positive integer n, let σ<sub>2</sub>(n) be the sum of the > squares of its divisors. For example, > > σ<sub>2</sub>(10) = 1 + 4 + 25 + 100 = 130. > > Find the sum of all n, 0 < n < 64,000,000 such that σ<sub>2</sub>(n) is a perfect square. This *Mathematica* code takes something like an hour to run on a modern machine: Sum[If[IntegerQ @ Sqrt @ DivisorSigma[2, i], i, 0], {i, 64*^6 - 1}] ~Monitor~ i // Timing The similarly naive PARI/GP code takes a minute or two: sum(n=1,64*10^6,issquare(sigma(n,2))*n) Is there some way to make the *Mathematica* code fast, or otherwise solve the problem quickly in *Mathematica* without involved mathematical reasoning to reduce the problem? Using [a faster perfect square test][1] helps quite a bit but it it still far from the PARI/GP performance. Compilation does not seem possible as numbers exceed the maximum machine-size integer. (*To foil search engines please do not mention the number of the Project Euler problem related to this question. Thanks.) [1]: http://mathematica.stackexchange.com/a/467/121