16,749
社区成员
发帖
与我相关
我的任务
分享
procedure TSDIAppForm.Button4Click(Sender: TObject);
Function NMN(i:Integer): Integer;
Begin
Result:= Ceil(Power(i,i));
End;
var
S, Temp: Int64;
I: Integer;
begin
S := 1;
for I := 1 to 100 do
Begin
Temp := NMN(I);
S := S * Temp;
if S >100000000 then
Begin
lblResult.Caption := FloatToStr(S / Temp);
Break;
End;
End;
end;
program factCalc;
{$APPTYPE CONSOLE}
var
i,j,n,w : longint;
a : array[1..1000] of integer;
procedure fact(k : longint);
var
x,i : longint;
begin
x := 0;
for i := 1 to w do
begin
a[i] := a[i]*k+x;
x := a[i] div 10;
a[i] := a[i] mod 10;
end;
while x>0 DO
begin
w := w+1;
a[w] := x mod 10;
x := x div 10;
end;
end;
begin
a[1] := 1;
w := 1;
readln(n);
for i := 1 to n do fact(i);
for j := w downto 1 do write(a[j]);
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormPaint(Sender: TObject);
var temp,s,i,j:dword;
n:integer;
Overflow:boolean;
begin
s:=1;
n:=0;
Overflow:=false;
for i:=1 to 100 do
begin
temp:=i;
for j:=2 to i do
if (temp*temp>100000000)or(temp*temp<1) then
begin
Overflow:=true;
break;
end
else temp:=temp*i;
if Overflow then break
else if (temp*s>100000000)or(temp*s<1) then break
else s:=s*temp;
inc(n);
Canvas.TextOut(30,n*20,inttostr(temp)+' n='+inttostr(n));
end;
Canvas.TextOut(30,(n+1)*20,format('合题意的数为:%d ; n = %d ',[s,n]));
end;
end.
procedure Test;
var
s,n,t: Integer;
begin
n := 0;
t := 1;
s := 1;
repeat
inc(n);
s := t;
t := S * N * N;
until t > 100000000;
Dec(N);
ShowMessage(Format('S=%d, N=%d, t=%d',[s, n, t]));
end;