Calculate Factorial of a Given Number in Python
February 11, 2013 Leave a comment
def factorial(x):
if x<0:
return “Error: negative number”
y=1
while x>0:
y=y*x
x=x-1
return y
i=eval(input(“Enter number : “))
print(factorial(i))
#Note : python differentiates between blocks of code through indentation so before running the code do not forget to indent it properly.