To find factorial of any number in python, you have to ask from user to enter the number to find and print the factorial of that number on the output screen.
Following python program ask from user to enter a number to find the factorial of that number:
# Python Program - Find Factorial of a Number while True: print("Enter 'x' for exit.") num = input("Enter a number: ") if num == 'x': break else: number = int(num) if number == 0: print("Factorial of 0 is 1\n") elif number < 0: print("Factorial of negative numbers doesn't exist..!!\n") else: fact = 1 for i in range(1, number+1): fact = fact*i print("Factorial of", number, "is", fact, "\n")
Here is the sample run of the above Python program to demonstrate how to find factorial of a number:
You may also like to learn or practice the same program in other popular programming languages: