Never approached this kind of program before, need help.
1 次查看(过去 30 天)
显示 更早的评论
So I'm supposed to write a program that calculates how many terms it takes for (1/1)+(1/2)+(1/3)+(1/4)...(1/n) shall be more than 4.
I can't use matlabs built-in functions (sum, sorting). Thank you!
0 个评论
采纳的回答
Star Strider
2016-2-2
Use a while loop, and keep track of the accumulating sum in each iteration.
2 个评论
Star Strider
2016-2-3
I was thinking something like this:
series_sum = 0;
k1 = 0;
while series_sum <= 4
k1 = k1 + 1;
series_sum = series_sum + 1/k1;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!