input: Write a function to calculate the sum of an exponential series up to a specified number of terms. The function should take two arguments, x and n, where x is the base of the exponential term and n is the number of terms to sum. If the number of terms is 0, the function should return 1.
  
  assert exponential_series(2, 3) == 15
  assert exponential_series(3, 2) == 13
  assert exponential_series(2, 0) == 1
  assert exponential_series(1, 5) == 6
  assert exponential_series(0, 4) == 1
output: def exponential_series(x, n):
      if n == 0:
          return 1
      sum = 0
      for i in range(n):
          sum += x ** i
      return sum