The factorial of the provided positive integer num is calculated by this program using a recursive function called factorial. As the factorial is not specified for negative values, it checks to see whether the input is negative and shows an error notice if it is.