function x = factorial(n)
%recursive function that calculate the factorial
%of a positive integer

%howdy
fprintf('\nEntering factorial of %d\n', n);
if n < 2
  x = 1;
  fprintf('n is less than 2 so return 1\n');
else
  fprintf('n is 2 or greater (%d), so recurse\n', n);
  x = n * factorial(n-1);
  fprintf('just returned from recursion with n being %d, x now %d\n',n-1,x);
end
fprintf('exiting computation of factorial of %d\n\n', n);

