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