这是delphi百例课堂里面的计算阶乘一段源码
procedure TForm1.Button1Click(Sender: TObject);
var
fac:integer;
n,i:integer;
begin
n:=strtoint(inputbox('输入','输入一个20以内的整数','10'));
label1.Caption:=inttostr(n);
fac:=1;
for i:=n downto 2 do
fac:=fac*n;
label1.caption:=inttostr(n)+'!='+inttostr(fac);end;end.
假设n=5,那么它的阶乘结果为5x4x3x2x1=120,可程序运行的结果为625,求解。