A FUNCTION that computes the sum of a geometric series 1 + r + r^2 + r^3 + r^4 + … + r^n, for a given r and N. THe input to the function must be 'r' and 'n'
Not sure what I am doing wrong, but I was trying to take baby steps and work it into a function but that didn't execute.
% create a vector with n elements all identical to r
v = r*ones(1,n); % calculate [r r^2 r^3….r^n]
v = cumprod(v); % sum and add one
geoSum = 1 + sum(v);
Best Answer