I am trying to get the answer for the sum to infinity for a geometric series. My output should be 3/2 and a loop should be used. I've done that but it won't work. Please help

3 ビュー (過去 30 日間)
Sequence = [1 1/3 1/9 1/27];
FirstTerm = Sequence(1);
CommonRatio = Sequence(2)/Sequence(1);
n = 0;
if (Sequence(2)/Sequence(1)) == (Sequence(end)/Sequence(end-1))
CommonRatio;
for i = 0:1:10000
n = n+1;
Sum2Infinity = FirstTerm * CommonRatio.^n;
end
end
disp(Sum2Infinity)

採用された回答

Torsten
Torsten 2023 年 3 月 28 日
編集済み: Torsten 2023 年 3 月 28 日
Sum2Infinity = 0.0;
for i = 0:1:10000
Sum2Infinity = Sum2Infinity + FirstTerm * CommonRatio^i;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by