function output = factorial(n)

    if n < 2
        output = 1;
    else
        output = n * factorial(n - 1);
    end

end