Код:
function myfact(n: integer): integer;
begin
if n <= 1 then Result := 1;
if n > 1 then Result := n * myfact(n - 1);
end;
function myPower(a, b: real): real;
begin
Result := exp(b * ln(a));
end;
function mycos(c: real; it: integer): real;
var
i: byte;
begin
Result := 1;
for i := 1 to it do
begin
if (i mod 2) = 1 then
Result := Result - (myPower(c, i*2) / myfact(i*2));
if (i mod 2) = 0 then
Result := Result + (myPower(c, i*2) / myfact(i*2));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := FloatToStr(cos(3.14/2));
Label2.Caption := FloatToStr(mycos(3.14/2,5));
end;
Некогда объяснять. Писал на коленке. devision by zero ... ожидаемо