By mathematica:
Clear["`*"]; Do[x[i]=Input["Enter the value of x"]; y[i][1]=Input["Enter the corresponding value of y"],{i,1,4}]; divided[r_,q_]:=Module[{x1=r,n=q},ans=0; Do[ex=1; Do[If[ij,ex=ex((x1-x[j])/(x[i]-x[j]))],{j,1,n}]; ans=ans+(ex)y[i][1],{i,1,n}]; Print["Recquired Result : ",ans//N]]; divided[301,4];