用matlab求1!+2!+...+50!
时间: 2023-11-24 12:51:34 浏览: 75
汇编实验报告6 计算1+2+……+50的值
以下是用Matlab求1!+2!+...+50!的方法:
```matlab
function x = sumNum(i)
sumNum(1) = 1;
for i = 2:50
p = 1;
for k = 1:i
p = p * k;
end
sumNum(i) = sumNum(i-1) + p;
end
x = sumNum(50);
```
调用该函数即可得到结果:
```matlab
>> sumNum(50)
ans =
3.041409320171337e+64
```
阅读全文