How can I find the first integer n for which the sum of the numbers below is greater than 2.5?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
1+1/2+1/3+1/4+...+1/n>2.5
0 comentarios
Respuestas (1)
DGM
el 15 de Feb. de 2022
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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!