function a = factorial(num)
    if num <= 1
        a = 1;
    else
        a = num * factorial(num - 1);
    end
end