input: Write a function to calculate the sum of an exponential series up to the nth term for a given base x. The function should return the sum of the series. If the given value of n is 0, the function should return 1.
  
  def exponential_series(x, n):
      sum = 0
      for i in range(n + 1):
          sum += x ** i
      return sum
  
  assert exponential_series(2, 4) == 31
  assert exponential_series(3, 3) == 40
  assert exponential_series(1, 5) == 6
  assert exponential_series(0, 0) == 1
  assert exponential_series(1, 0) == 1
output: def exponential_series(x, n):
      sum = 0
      for i in range(n + 1):
          sum += x ** i
      return sum