input: Write a function to perform linear regression on a given dataset and predict the value of y for a new x value. If the prediction is successful, return the predicted value, otherwise return None. If the input dataset is empty, return None.
  assert linear_regression([1,2,3,4,5], [3,5,7,9,13])==15.0
  assert linear_regression([10, 20, 30, 40, 50], [100, 200, 290, 380, 470])==560.0
  assert linear_regression([], [])==None
  assert linear_regression([2, 4, 6], [4, 8, 12])==16.0
  assert linear_regression([5, 10, 15], [10, 20, 30])==20.0
output: def linear_regression(x_values, y_values):
      if not x_values or not y_values:
          return None
      
      n = len(x_values)
      sum_x = sum(x_values)
      sum_y = sum(y_values)
      sum_x_squared = sum(x**2 for x in x_values)
      sum_xy = sum(x*y for x, y in zip(x_values, y_values))
      
      slope = (n * sum_xy - sum_x * sum_y) / (n * sum_x_squared - sum_x**2)
      intercept = (sum_y - slope * sum_x) / n
      
      new_x = x_values[-1] + (x_values[-1] - x_values[-2])
      predicted_y = slope * new_x + intercept
      
      return predicted_y