Question: Using MatLab and with explanation if possible please: Exercise W1.1 (four different ways to sum). Recall the summation formula n(n+1) i= (W1.1.1) 2 n i=1

Using MatLab and with explanation if possible please:  Using MatLab and with explanation if possible please: Exercise W1.1 (four

Exercise W1.1 (four different ways to sum). Recall the summation formula n(n+1) i= (W1.1.1) 2 n i=1 Write a code that takes a positive integer n e N as input and outputs the sum of the first n natural numbers (strictly positive integers), using: (a) a for loop; (b) a while loop; (c) a recursive code; (d) in Octave/Matlab or Python using an array (also known as vector, list or finite sequence), the column construct and the built-in function sum . Test your code for n= 10, n=20 and n= 100, against the known result" that you are able to compute from (W1.1.1). Do not forget the special case n=0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!