Factorial Program in Python
Tagged:
The factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 6! = 1 x 2 x 3 x 4 x 5 x 6 = 720. Below is a python program to identify this number.
n = input("enter positive integer:")
if n < 0:
print "error: you entered negative integer"
else:
product = 1
for i in range(1, n+1):
product = product * i
print n, "!=", product
ouput
![]()

ans = 1
text = str(ans)
for i in range(2, n+1 ):
text += " X " + str(i)
ans *= i
print(text, " = ", ans)
hi sir..
in this program..
how can i add/make/display the solution like in 6! ,
it will display "1 x 2 x 3 x 4 x 5 x 6"
Post new comment