Matlab Q2 Partial sum of integers Write a program using a FO
Matlab
Q2. Partial sum of integers
Write a program using a FORLOOP to calculate the sum of integers up to N. Set the value of N at the beginning of the program. (N=100 was Gauss’s famous trick).
P(n)= k (here k=1 to n)
Please post the code!
Solution
v = input (\'v=\'); result=0; for x= (1:v) result=result+x; end end disp(result);