function myApp(n, nslots)
% Sample user application
% Purpose: Computes Arithmetic Sequence Sum  s = 1+2+3+ . . . +n
% parfor reduces to for if parallel pool (matlabpool or parpool) 
% is not invoked (parpool may default to invoke automatically).

% Compute sum with Parallel Computing Toolbox's parfor
matlabpool('local', nslots);  % R2013a or older
%parpool('local', nslots);    % R2014a or newer
s = 0;    % initialize solution
parfor i=1:n
    s = s + i;       % s = 1 + 2 + 3 + . . . + n
end
%delete(gcp);      % R2014a or newer (to return resources)
matlabpool close;  % R2013a or older (to return resources)

end   % end of function

