$tot = 0; for ($i = 2; $i < 1000000; $i++) { $s = 0; for ($j = 0; $j < length($i); $j++) { $s += (substr($i,$j,1) ** 5); } if ($s == $i) { print "$i "; $tot += $i; } } print "\n----\n$tot\n"; ;