using For loop function to find the sum of the number

2 次查看(过去 30 天)
I want to know how to solve this problem

回答(1 个)

Voss
Voss 2022-2-8
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.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by