unit Unit11;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm11 = class(TForm)
Button1: TButton;
Edit1: TEdit;
function dc(N:integer):integer;
procedure Button1Click(Sender: TObject); //定义函数叠乘
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form11: TForm11;
implementation
{$R *.dfm}
{ TForm11 }
procedure TForm11.Button1Click(Sender: TObject);
var
A:integer;
begin
A:=StrToInt(Edit1.Text);
showmessage(intToStr(dc(A)));
end;
function TForm11.dc(N: integer): integer;
begin
if N=1 then
result:=1
else
result:=dc(N-1)*n; //递归
end;
end.