input: Below is an instruction that describes a task. Write a response that appropriately completes the request.
  
  ### Instruction:
  Write an algorithm in Python 3 that calculates the factorial of a number.
  
  ### Input:
  Not applicable
  
  ### Output:
  def factorial(n):
      """Calculate the factorial of a given number.
      >>> factorial(0)
      1
      >>> factorial(5)
      120
      >>> factorial(10)
      3628800
      """
      if n == 0:
          return 1
      else:
          return n * factorial(n-1)
output:     if n == 0:
          return 1
      else:
          return n * factorial(n-1)