===== PascalABC.NET =====
function Coeff(x, y: array of real): (real, real);
begin
var Sx := x.Sum;
var Sy := y.Sum;
var Sx2 := x.Sum(p -> p * p);
var Sxy := x.Zip(y, (p, q) -> p * q).Sum;
var n := x.Length;
var a0 := (Sy * Sx2 - Sxy * Sx) / (n * Sx2 - Sqr(Sx));
var a1 := (n * Sxy - Sy * Sx) / (n * Sx2 - Sqr(Sx));
Result := (a0, a1)
end;
var n := ReadInteger('Количество точек:');
var x := ReadArrReal('Значения х:', n);
var y := ReadArrReal('Значения y:', n);
var (a0, a1) := Coeff(x, y);
$'a0 = {a0}, a1 = {a1}'.Print
end.
===== PascalABC.NET =====
function Coeff(x, y: array of real): (real, real);
begin
var Sx := x.Sum;
var Sy := y.Sum;
var Sx2 := x.Sum(p -> p * p);
var Sxy := x.Zip(y, (p, q) -> p * q).Sum;
var n := x.Length;
var a0 := (Sy * Sx2 - Sxy * Sx) / (n * Sx2 - Sqr(Sx));
var a1 := (n * Sxy - Sy * Sx) / (n * Sx2 - Sqr(Sx));
Result := (a0, a1)
end;
begin
var n := ReadInteger('Количество точек:');
var x := ReadArrReal('Значения х:', n);
var y := ReadArrReal('Значения y:', n);
var (a0, a1) := Coeff(x, y);
$'a0 = {a0}, a1 = {a1}'.Print
end.