input: def exponential_series(x: float, n: int) -> float:
      """ Calculate the sum of the first n+1 terms of the exponential series for x.
      >>> exponential_series(2, 3)
      15.0
      >>> exponential_series(1, 5)
      6.0
      """
output:     result = 0.0
      for i in range(n + 1):
          result += x ** i / math.factorial(i)
      return result