matlab
40585 = 4! + 0! + 5! + 8! + 5!
게으른 the lazy
2025. 3. 16. 22:32

의심이 많은 나는 코드로 확인해본다.
i = 0;
while true
i = i + 1;
list = num2str(i) - '0';
if i == sum(factorial(list))
fprintf('%d = ', i)
for n = 1:length(list)-1
fprintf('%d! + ', list(n))
end
fprintf('%d!\n', list(end))
keyboard
end
end
1 = 1!
2 = 2!
145 = 1! + 4! + 5!
40585 = 4! + 0! + 5! + 8! + 5!
이 이후로는 370만까지 나오지 않았다. 9!는 기껏해야 362880이므로 이 이후로는 나오지 않는다.
끗