import math math.factorial(5) # Using math module def factorial(n): # Doing it yourself x = 1 for i in range(2,n+1): x *= i return x