MATLAB:用for循环求1、2、……100的和以及用函数文件求前N项和 1、 A=0 for i=1:100; A=A+i ; end A 或 sum([1:100]) 2、 function n=A(n) if n==1 n=1; else n=n+A(n-1) end