input: Write a function to perform linear regression on a given dataset for predicting the values of the target variable. The function should fit a linear regression model using the input data and predict the value of the target variable for a given input.
  assert linear_regression([1,2,3,4,5], [3,5,7,9,13], 7)==17.0
output: def linear_regression(X, y, x_new):
      n = len(X)
      sum_X = sum(X)
      sum_y = sum(y)
      sum_X_squared = sum(x*x for x in X)
      sum_Xy = sum(X[i]*y[i] for i in range(n))
      
      slope = (n * sum_Xy - sum_X * sum_y) / (n * sum_X_squared - sum_X**2)
      intercept = (sum_y - slope * sum_X) / n
      
      return slope * x_new + intercept