input: Write a function to perform linear regression for predicting the numbers in a given dataset. The function should take two lists X and Y, where X represents the input features and Y represents the target values. The function should return the predicted value of Y for a new input.
  assert linear_regression([1,2,3,4,5], [3,5,7,9,13], 7)==13.0
  assert linear_regression([1,2,3,4,5], [2,3,4,5,6], 6)==8.0
  assert linear_regression([1,3,5,7,9], [2,4,6,8,10], 11)==12.0
  assert linear_regression([1,2,4,6,8], [2,4,8,12,16], 10)==20.0
  assert linear_regression([1,3,4,5,9], [2,7,9,11,20], 13)==26.0
output: def linear_regression(X, Y, new_input):
      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
      
      return slope * new_input + intercept