Factorial of a Number
Problem Statement
Suggest Edit
Problem Statement
The only line of input contains a single integer.
The only line of output prints the Factorial of the number or "Error" if it doesn't exist.
-10 <= n <= 12
5
120
5!=5*4*3*2*1=120
0
1
Its a fact that 0!=1
-2
Error
It's a fact that we can't find the factorial of a negative number.
#Your code goes here n=int(input()) res=1 if n<0: print("Error") elif n==0: print(1) else: for i in range(1,n+1): res*=i print(res)
Comments
Post a Comment