# # Compute n-factorial using a function. # # Compute the value of n-factorial. def factorial(n): # Initialize result. result = 1 # Multiply result by 1, 2, 3 ... n-2, n-1, n for factor in range(1, n + 1): result = result * factor # Return the result. return result # Read an integer from the user, compute its factorial, and display the result. def main(): n = int(input("Enter a non-negative integer: ")) r = factorial(n) print(f"{n} factorial is equal to {r}.") # Call the main function. main()