function x = faculty(n) % return the faculty of n x = 1; for i = 1:n x = x * i; end % x = prod(1:n) % this is a one line alternative to the for loop! end