(Solved) Help with please these are hard

;
' Write a function called threshold that determines the number of terms required for the sum
In other words, your output arguments are terms that gives the number of n required for
sum to exceed a limit; and total that gives that sum.'

2 件のコメント

Rik
Rik 2021 年 5 月 27 日
Why did you edit away parts of your question? That is very rude.
Rena Berman
Rena Berman 2021 年 6 月 29 日
(Answers Dev) Restored edit

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

 採用された回答

Torsten
Torsten 2021 年 5 月 26 日
編集済み: Torsten 2021 年 5 月 26 日

0 投票

function [n,summa] = threshold(limit)
summa = 0;
n = 0;
while summa <= limit
n = n+1;
summa = summa + 5*n^2 - 2*n;
end

1 件のコメント

Torsten
Torsten 2021 年 5 月 26 日
編集済み: Torsten 2021 年 5 月 26 日
I edited my answer.

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

その他の回答 (1 件)

Nikita Agrawal
Nikita Agrawal 2021 年 5 月 26 日

0 投票

function [number_of_terms] = threshold(limit)
T = 0;
k=1
while T < limit
T = T + 5*k*k-2*k;
k = k+1;
end
number_of_terms=k
end

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2021 年 5 月 26 日

コメント済み:

2021 年 6 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by