(Gast)
n/a Beiträge
|
Re: Fakultät berechnen
14. Okt 2005, 14:18
Wenn es denn hilft...
Delphi-Quellcode:
var
Form1: TForm1;
n : integer;
F : Double;
k : Integer;
implementation
{$R *.DFM}
procedure TForm1.Beenden1Click(Sender: TObject);
begin
close;
end;
function Fakult1(k : integer): Double;
var
i : Integer;
a : Integer;
begin
result := 1;
a := i;
for a := 2 to k do
result := a*result;
end;
function Fakult2(k : integer): Double;
begin
if k = 0 then
Fakult2 := 1 else Fakult2 := k*Fakult2(k-1);
end;
procedure Fakult3(k: Integer; var f : double);
begin
if k=0 then f:=1 else
begin
Fakult3(k-1,f);
f:=k*f;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
k := Spinedit1.Value;
Fakult1(k);
Fakult2(k);
Fakult3(k,f);
|
|
Zitat
|