unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
fac:integer;
n,i:integer;
begin
n:=strtoint(inputbox('输入','输入一个不太大的整数','5'));
label1.Caption :=inttostr(n);
fac:=1;
for i:=n downto 2 do
fac:=fac*i;
label1.caption:=inttostr(n)+'!='+inttostr(fac);
end;
end.