While Loop Homework Question
37 ビュー (過去 30 日間)
古いコメントを表示
Nicholas Bieganski
2020 年 11 月 4 日
コメント済み: Nicholas Bieganski
2020 年 11 月 4 日
Hey everyone, I have a homework assignment due today and I can't figure out this question: Write a MATLAB repetition structure to determine how many terms in the sum 1+2+3+... are required for the sum to exceed one million (1e+6). Display how many terms are required and what is the first sum that exceeds one million in one sentence in the command window. Could someone help me out? I really can't find a way to figure it out so it would be awesome and really helpful is someone could help me.
2 件のコメント
採用された回答
Stephen23
2020 年 11 月 4 日
You were close, here is your code with a few small changes:
k = 0;
a = k;
while a<1e6
k = k+1;
a = k+a;
end
disp(k)
disp(a)
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!