W
wdycwopt
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么只能算到170的阶乘(而170的阶乘只是E306,而Extended能容下E4932呢。)?
function factorial(n:extended):extended;
begin
result:=1;
while n>1 do
begin
result:=result*n;
n:=n-1;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
num:extended;
begin
num:=strtoint(edit1.Text);
if num>170 then
showmessage('输入的数据不能大于170!')
else
edit2.Text:=Floattostr(factorial(num));
end;
function factorial(n:extended):extended;
begin
result:=1;
while n>1 do
begin
result:=result*n;
n:=n-1;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
num:extended;
begin
num:=strtoint(edit1.Text);
if num>170 then
showmessage('输入的数据不能大于170!')
else
edit2.Text:=Floattostr(factorial(num));
end;