Effacer les filtres
Effacer les filtres

(Solved) Help with please these are hard

1 vue (au cours des 30 derniers jours)
Ali Ece
Ali Ece le 26 Mai 2021
Commenté : Rena Berman le 29 Juin 2021
;
' 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 commentaires
Rik
Rik le 27 Mai 2021
Why did you edit away parts of your question? That is very rude.
Rena Berman
Rena Berman le 29 Juin 2021
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponse acceptée

Torsten
Torsten le 26 Mai 2021
Modifié(e) : Torsten le 26 Mai 2021
function [n,summa] = threshold(limit)
summa = 0;
n = 0;
while summa <= limit
n = n+1;
summa = summa + 5*n^2 - 2*n;
end
  1 commentaire
Torsten
Torsten le 26 Mai 2021
Modifié(e) : Torsten le 26 Mai 2021
I edited my answer.

Connectez-vous pour commenter.

Plus de réponses (1)

Nikita Agrawal
Nikita Agrawal le 26 Mai 2021
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

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by