function[output] = factorial2(input) 
    if input < 0 | rem(input, 1) ~= 0 % if a number is negative or not an integer
        error("You did not input a non-negative integer!")
    elseif input == 0 % if the input is zero
        output = 1;
    else % positive integers
        x = 1; % inicialize x as x = 1
        for i = 1:input 
            x = x * i; % mute computations using ;
        end
        output = x;
end