% Recursion
function result = rsum(n)
   if n==1
      result = 1;
   else
      result = n + rsum(n-1);
   end

% Actually this case handled much quicker by MATLAB itself
% sum(1:n)
% could also do loop
