フィルターのクリア

While loop for sum

4 ビュー (過去 30 日間)
Rui Hou
Rui Hou 2021 年 4 月 12 日
コメント済み: Rui Hou 2021 年 4 月 12 日
Hi,
I need to read in an integer N from the keyboard and then use while loop to compute the value of the expression.
The expression is ((n+1)/sqrt(n)+n^3)

採用された回答

Walter Roberson
Walter Roberson 2021 年 4 月 12 日
n = 1;
while true
do something
n = n + 1;
if n > N; break; end
end
or
n = 0;
while true
n = n + 1;
if n > N; break; end
do something
end
or
n = 1;
while true
do something
if n >= N; break; end
n = n + 1;
end
or
n = 1;
while n <= N
do something
n = n + 1;
end
or
n = 0;
while true
if n > N; break; end
n = n + 1;
do something
end
  1 件のコメント
Rui Hou
Rui Hou 2021 年 4 月 12 日
That helps! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by