题目如下:
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
![]()
As 1 =
is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
算是水仙花数的升级版本吧
clear;clc;close all
c = [];
for i = 2 : 1e6
n = ceil(log10(i+1));
if sum(mod(floor(i./10.^(0:n-1)),10).^5)==i
c = [c,i];
end
end
sum(c)