Question

In MATLAB

Write a script to determine the number of terms required for the sum of the series (5k? – 2k) not to exceed 100,000 using the

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc;
clear;
close all;
sum = 0;
max = 100000;
k = 0;
while (sum < max)
k = k+1;
sum = sum + (5*k^2 - 2*k);
if sum > max
n = k-1;
sum = sum - (5*k^2 - 2*k);
break
end
end
fprintf('The number of terms is %g and its sum is %g \n',n,sum);

EDITOR PUBLISH VIEW 1 Run and Advance Find Files Insert fx FH Compare Go To Comment % 93% New Open Save Breakpoints Run PrintCommand Window The number of terms is 38 and its sum is 93613 fx >> |

Add a comment
Know the answer?
Add Answer to:
In MATLAB Write a script to determine the number of terms required for the sum of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT