While loop for sum
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I need to read in an integer N from the keyboard and then use while loop to compute the value of the expression.
The expression is ((n+1)/sqrt(n)+n^3)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/580332/image.png)
0 commentaires
Réponse acceptée
Walter Roberson
le 12 Avr 2021
n = 1;
while true
do something
n = n + 1;
if n > N; break; end
end
or
n = 0;
while true
n = n + 1;
if n > N; break; end
do something
end
or
n = 1;
while true
do something
if n >= N; break; end
n = n + 1;
end
or
n = 1;
while n <= N
do something
n = n + 1;
end
or
n = 0;
while true
if n > N; break; end
n = n + 1;
do something
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!