function output = factorial(n)

    if n == 0
        output = 1; % base case
    else
        output = n * factorial(n - 1); % recurrence relation
    end
end
