input: Write a function to calculate the sum of an exponential series of the form \(1 + x + x^2 + x^3 + \ldots + x^n\). The function should take in two parameters, x and n, and return the sum of the series.
  
  assert exponential_series(2, 3) == 15
  assert exponential_series(2, 4) == 31
  assert exponential_series(3, 2) == 13
  assert exponential_series(0, 5) == 1
  assert exponential_series(1, 10) == 11
output: def exponential_series(x, n):
      return (x ** (n + 1) - 1) // (x - 1) if x != 1 else n + 1