input: Write a function to calculate an exponential series. The function should take two parameters, x (the base) and n (the number of terms in the series), and return the sum of the exponential series up to n terms.
  
  assert exponential_series(2, 3) == 15
  assert exponential_series(3, 4) == 121
  assert exponential_series(1, 5) == 6
  assert exponential_series(0, 10) == 1
  assert exponential_series(4, 2) == 21
output: def exponential_series(x, n):
      result = 0
      factorial = 1
      for i in range(n):
          if i > 0:
              factorial *= i
          result += x ** i / factorial
      return result