MATLAB: How to calculate this sym of serie

seriesum

z=q+q*(q-1)+q*(q-1)*(q-2)+…+q*(q-1)*(q-2)*…*(q-n)

Best Answer

Try this intuitive, brute force method:
clc;
% Sample numbers:
q = 10;
n = 3;
theSum = 0;
for k = 0 : n
qArray = q : -1 : q-k;
p = prod(qArray)
theSum = theSum + p;
end
% Print to command window
theSum