Consider the following Matlab code, which was written to reproduce a telescoping series
Mo=-1;
Mn=0;
n=1;
while (Mn-Mo)>0.00001
Mo=Mn;
Mn=Mn+1/n*(n+1);
n=n+1;
end
The code, as it appears above, does not yield the desired result. Identify what is wrong with the code, correct it, and report the resulting sum to four significant figures

回答 (1 件)

KSSV
KSSV 2020 年 8 月 14 日

0 投票

n = 10000 ;
thesum = 0 ;
for i = 1:n
thesum = thesum+1/(n*(n+1)) ;
end

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

製品

リリース

R2019b

質問済み:

2020 年 8 月 14 日

回答済み:

2020 年 8 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by