In: Mechanical Engineering
Use a for loop to determine the sum of the rst 10 terms in the series 5k3, k % 1, 2, 3, . . . , 10.
Using loop:
function s=series()
%initialize sum is zero
sum=0;
% Create loop i until 10
for i=1:10
sum=sum+5*i^3; % Calculate sum of value
end % end of the for loop
s=sum; % assign resultant series to s
end % end the of the function
Output:
Answer = 15125
Output:
Answer = 15125