using For loop function to find the sum of the number

2 vues (au cours des 30 derniers jours)
Joseph
Joseph le 8 Fév 2022
Commenté : Stephen23 le 8 Fév 2022
I want to know how to solve this problem

Réponses (1)

Voss
Voss le 8 Fév 2022
Well, if the question were how to find the sum of the even numbers between 2 and 102, inclusive, using a for loop, you could say:
total = 0;
for ii = 2:2:102
total = total+ii;
end
Maybe you can use the same approach for the actual question.

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!

Translated by