input: To generate a Python function for finding the factorial of a given number, we need to write a function that starts with a function header and includes both a description and example test cases. The instruction doesn't require additional text or different formatting than what is provided.
  
  ---
  
  Here's the formatted Python function:
  
  
  def factorial(n):
      """
      Calculate the factorial of a given number.
      
      Example:
      >>> factorial(7)
      5040
      """
      fact = 1
      for i in range(2, n + 1):
          fact *= i
      return fact
  
  
  This function calculates the factorial of a given number `n` and includes one example test case for `n = 7`, which should output `5040`.
output:     if n == 0:
          return 1
      else:
          return n * factorial(n - 1)