MATLAB: Can someone help me with a question to do with sequences and creating a function file that find n terms of sequence

homeworkn term function file

Can someone show me the function file that would calculate the first n terms of this sequence a_i=a_(i-1)+3i as well as the sum of the first n terms please!

Best Answer

a = a_0 + cumsum(3:3:3*n); % The sequence of first n terms
s = sum(a); % The sum of these