(** Zadacha 4 **)
Print["Zadacha 4"]
Print["n="]
n = Input["Vuvedete n:"]
X = Range[-4, 4];
Y  = {4, 7, 4, -1, 1, 5, 6, 13, 15};
len = Length[X];
plotList = ListPlot[Table[{X[[i]], Y[[i]]}, {i, 1, len}], PlotMarkers->■];
MatA = Table[(∑_(k=1)^len)If[X[[k]] ==0, 0, X[[k]]^(i+j)], {i, 0, n}, {j, 0, n}];
MatY = Table[(∑_(k=1)^len)If[X[[k]]==0, 0, Y[[k]] * X[[k]]^i], {i, 0, n}];
SolutionCoeff = LinearSolve[MatA, MatY];
Polynomial[x_] = (∑_(k=0)^n)SolutionCoeff[[k+1]]*x^k
plotPoly = Plot[Polynomial[x], {x, X[[1]], X[[len]]}];
Show[ plotList, plotPoly]