Write a program that asks the user for an integer greater than 0 and then use a for-loop to
calculate the factorial of that positive integer.
Modify your program so that the output looks like the following:
Example: 5! = 5 x 4 x 3 x 2 x 1 = 120
n = int(input("enter a number greater than 0: "))
factorial = 1
for i in range(1, n + 1):
factorial = factorial * i
print("factorial of ", n, " is ", factorial)
Comments
Leave a comment