k=1;s=0;for i=1:10k=k*i;s=s+k;enddisp(s)
结果:
4037913
sum=0;prod=1;for i=1:10 for j=1:i prod=prod*j; end sum=sum+prod; prod=1;endsum=0;for i=1:10 sum=sum+factorial(i);end