# Compute n-factorial using a function. # # Compute the factorial of a number # # Parameters: # n: An integer for which the factorial is being computed. Returns # 1 if n is a negative number. # # Returns: # n-factorial # def factorial(n): result = 1 for i in range(1, n+1): result = result * i return result # # Compute n-factorial for a number entered by the user. # # Parameters: (None) # # Returns: (None) # def main(): a = int(input("Enter a non-negative integer: ")) print(a, "factorial is", factorial(a)) # Start the main function main()