matlab循环求和,来看看
发布网友
发布时间:2022-04-29 20:25
我来回答
共1个回答
热心网友
时间:2023-10-08 20:17
tic;
K=0;
for i=1:10^2;
K=K+sqrt(5)/(3^i);
end;
K,
toc,
tic;
K=0;
n=1;
while n<=10^2;
K=K+sqrt(5)/(3^n);
n=n+1;
end;
K,
toc,
tic;
m=1:10^2;
k=sqrt(5)./(3.^m);
K=sum(k),
toc,
K =
1.1180
Elapsed time is 0.002072 seconds.
K =
1.1180
Elapsed time is 0.001988 seconds.
K =
1.1180
Elapsed time is 0.001814 seconds.
迈特莱博追问是10的七次方,已经解决了,不过谢谢你哈,嘿嘿