If we have a 3 digit number then the maximum sum of the digits to fifth power is 9
5+9
5+9
5 = 3*9
5 = 177147
If we check the maximum sum of the digits to fifth power for different numbers of digits we find that the maximum number of digits is 6. For larger numbers with more digits, the maximum sum to 5th powers will always be less than the number.
This limits our search to 6 digit numbers.
For d = 1 To 10
TextWindow.WriteLine("Max sum of "+d+" digit number to 5th power = "+d*9*9*9*9*9)
EndFor
total = 0
For d1 = 0 To 9
s1 = d1*d1*d1*d1*d1
For d2 = 0 To 9
s2 = d2*d2*d2*d2*d2
For d3 = 0 To 9
s3 = d3*d3*d3*d3*d3
For d4 = 0 To 9
s4 = d4*d4*d4*d4*d4
For d5 = 0 To 9
s5 = d5*d5*d5*d5*d5
For d6 = 0 To 9
s6 = d6*d6*d6*d6*d6
sum = s1+s2+s3+s4+s5+s6
number = 100000*d1+10000*d2+1000*d3+100*d4+10*d5+d6
If (sum = number) Then
TextWindow.WriteLine("Solution found = "+number)
total = total+number
EndIf
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
TextWindow.WriteLine("Total = "+total)The answer after a few seconds of calculation is 443840