题目如下:
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: As 1! = 1 and 2! = 2 are not sums they are not included.
采用暴力方法
clear;clc;close all
c = factorial(0:9);
d = 0;
for i = 11 : 99999
n = ceil(log10(i+1));
m = mod(floor(i./10.^(0:n-1)),10);
p = sum(c(m+1));
if p == i
d = d + i;
end
end