input: Write a function to calculate the sum of the first n terms of an exponential series for a given base x. The function should return the total sum after adding up the powers of x from 0 to n.
  def exponential_series(x, n):
      sum = 0
      for i in range(n+1):
          sum += x ** i
      return sum
  assert exponential_series(2, 3) == 15
  assert exponential_series(3, 2) == 13
  assert exponential_series(1, 5) == 6
  assert exponential_series(0, 4) == 1
  assert exponential_series(-1, 4) == 0.5
output: def exponential_series(x, n):
      sum = 0
      for i in range(n+1):
          sum += x ** i
      return sum