The for loop.
9 ビュー (過去 30 日間)
古いコメントを表示
How do I write a for loop that finds the product of natural numbers from 1 to 50.
i.e. 1x2x3x4...x50
3 件のコメント
Stephen23
2019 年 4 月 23 日
Cebolenkosi Mandlanti's "Answer" moved here:
Not too accurate, I just want know how do I put it together.
Stephen23
2019 年 4 月 23 日
Well, it is not very hard to multiply values using a loop, so I presume that you must have tried something in the twenty-three minutes since you wrote your question. Please show us what you have tried so far.
回答 (1 件)
Ravi Chaitanya
2022 年 12 月 29 日
Hello Cebolenkosi,
As per my understanding, you want to multiply numbers from 1 to 50 using a for loop.
Below is the code snippet for the same:
product = 1;
for num = 1:50
product=product*num;
end
disp(product);
Thanks!
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!