CBSE Class 11 Computer Science
Question 62 of 80
Conditional and Looping Constructs — Question 32
Back to all questions 32
Question Write a program to accept a number and display the factorial of that number.
number = int(input("Enter a number: "))
factorial = 1
if number < 0:
print("Factorial is not defined for negative numbers.")
else:
for i in range(1, number + 1):
factorial *= i
print("The factorial of", number, "is", factorial)Enter a number: 5
The factorial of 5 is 120