input: Write a function to implement linear regression for predicting the numbers in a given dataset. The function should take two lists X and Y as input, where X is the independent variable and Y is the dependent variable. The function should return the predicted value of Y for a new value of X.
  assert linear_regression([1,2,3,4,5], [3,5,7,9,13])==[14.0]
  assert linear_regression([1,2,3,4], [2,4,6,8])==[9.0]
  assert linear_regression([0,1,2,3], [1,3,5,7])==[8.0]
  assert linear_regression([1,2,4,6], [2,4,8,12])==[14.0]
  assert linear_regression([1,2,3], [1,4,9])==[11.0]
output: def linear_regression(X, Y):
      n = len(X)
      sum_x = sum(X)
      sum_y = sum(Y)
      sum_xy = sum(x * y for x, y in zip(X, Y))
      sum_x2 = sum(x ** 2 for x in X)
      
      slope = (n * sum_xy - sum_x * sum_y) / (n * sum_x2 - sum_x ** 2)
      intercept = (sum_y - slope * sum_x) / n
      
      new_x = X[-1] + 1
      predicted_y = slope * new_x + intercept
      
      return [predicted_y]