1def factorial(n):
2 fact = 1
3 for num in range(2, n + 1):
4 fact = fact * num
5 return(fact)
1def factorial(n):
2 if n == 0:
3 return 1
4 else:
5 return n * factorial(n-1)
6n=int(input("Input a number to compute the factiorial : "))
7print(factorial(n))
8
9
1#Assumes n is possitive
2def factorial(n):
3 return 1 if n <=1 else n*factorial(n-1)
1# one line Logic factorial
2
3def factorial(i):
4 return 1 if (i==1 or i==0) else i * factorial(i-1)
5
6num = int(input('Enter Number : '))
7print('factorial of number', num, 'is',factorial(num))