Factorial of a Number
Programs with input · Intermediate · about 6 min
Read a whole number n and print its factorial, the product 1 * 2 * 3 * ... * n, as 5! = 120. The factorial of 0 is 1. For a negative number, print No factorial for negative numbers.
The prompts inside input() are not checked, only what you print.
Example
You type:
5The program prints:
5! = 120
n = int(input("Number: "))
# Print n! or the message for negative numbers
The solution opens after your first Check.