input: from typing import List
  
  def exponential_series(x: int, n: int) -> int:
      """
      Calculate the sum of the exponential series for the given value of x and up to n terms.
      >>> exponential_series(2, 4)
      31
      >>> exponential_series(3, 3)
      40
      """
      sum = 0
      for i in range(n+1):
          sum += x ** i
      return sum
output:     sum = 0
      for i in range(n+1):
          sum += x ** i
      return sum