# Compute n-factorial using a function # Compute the value of n factor # Parameters: # n: an integer greater than or equal to 0 # Returns: n-factorial def factorial(n): factor = n result = 1 while factor > 0: result = result * factor factor = factor - 1 return result # Compute the factorial of a number entered by the user def main(): # Read the input from the user a = int(input("Enter a non-negative integer: ")) # Compute the factorial result = factorial(a) # Display the result print("result is", result) main()