input: def exponential_series(x: float, n: int) -> float:
      """
      Calculate the sum of the first n+1 terms of the exponential series e^x.
  
      >>> exponential_series(2.0, 3)
      15.0
      >>> exponential_series(1.0, 5)
      2.7166666666666663
      """
      sum = 0
      for i in range(n + 1):
          sum += x ** i
      return sum
output:     sum = 0
      factorial = 1
      for i in range(n + 1):
          if i > 0:
              factorial *= i
          sum += x ** i / factorial
      return sum