Use a for loop to determine the sum of the first ten even terms in the series 5k3 (k=2, 4, 6, ….)
44 次查看(过去 30 天)
显示 更早的评论
I have the following but shows error. Please help
for k=2:10
total=5.*k^3;
end
disp('sum of the first ten even terms is: ')
disp(total)
0 个评论
回答(1 个)
James Tursa
2022-10-20
编辑:James Tursa
2022-10-20
You are summing all the terms with 2:10. For the "even" terms you need to skip the odd ones, so the range would be 2:2:something (the middle 2 means every other value starting at 2). You just need to figure out what the "something" value is in order to get ten even terms.
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!