Question: Write a function to compute the sum of the series S1 given as: S1=1-1/2+1/3-1/4+1/5-1/6+1/7-1/8+1/9-1/10..........1/N where, N is an odd positive integer; for the last term
Write a function to compute the sum of the series S1 given as: S1=1-1/2+1/3-1/4+1/5-1/6+1/7-1/8+1/9-1/10..........1/N
where, N is an odd positive integer; for the last term take (+) if N is odd and (-) if N is even The function should have one input N and one output S1. Make use of for_loop and if_statement. Name your function as LastName_FirstName_1. In the command window, test your function for N= 25 and N =125. Copy and paste the command window results into
your function as comments. Hint: You may need to make use of mod function available in Matlab
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
