How can I find the first integer n for which the sum of the numbers below is greater than 2.5?
1 次查看(过去 30 天)
显示 更早的评论
回答(1 个)
DGM
2022-2-15
Here's one simple way:
kmax = 10;
n = 1:kmax;
s = cumsum(1./n);
[n' s']
kest = n(find(s>2.5,1,'first'))
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!