function nfac = myFactorial(n)
% Nonrecursive code: uses a 'for' loop
%     nfac = 1; 
%     for i = 1:n
%         nfac = nfac * i; 
%     end

% Recursive code
    if n < 0 
        nfac = NaN; 
    elseif n == 0
        nfac = 1;
    else
        nfac = n * myFactorial(n-1);
    end
end