To find the Factorial of a number.
def factorial(n):
if n==1: return n
else: return n * factorial(n-1)
Factorial is a non-negative integer. It is the product of all positive integers less than or equal to that number you ask for factorial. It is denoted by an exclamation sign (!).
def fact(n):
return 1 if (n==1 or n==0) else n * fact(n - 1);
Using built-in function
import math
def fact(n):
return(math.factorial(n))