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
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!