# # Compute n-factorial for some n-value entered by the user # # Read n from the user n = int(input("Enter an integer: ")) # Save the original value of n so that it is available for the output message original_n = n # Initialize result to 1 result = 1 # Compute n-factorial # while n is greater than 0 while n > 0: # multiply the result so far by the current value of n, storing it back # into result result = result * n # decrease the value of n n = n - 1 # Display the result if n < 0: print("Couldn't compute the factorial of a negative number") else: print(original_n, "factorial is", result)