这其实是一道阶乘和的问题!
var
l,n,i,j,h,k:longint;
len:longint;
a,b:array[1..100] of longint;
begin
read(n);
a[1]:=1;
for i:=1 to n do
begin
k:=0;
for l:=1 to 100 do
begin
h:=a[l]*i+k;
a[l]:=h mod 10;
k:=h div 10;
end;
k:=0;
for l:=1 to 100 do
begin
h:=b[l]+a[l]+k;
b[l]:=h mod 10;
k:=h div 10;
end;
end;
len:=100;
while b[len]=0 do len:=len-1;
for j:=len downto 1 do
write(b[j]);
end.
var i,j,s,p:longint;
begin
s:=1;
for i:=1 to 50 do
begin
for j:=1 to i do
begin s:=s*j; end;
p:=p+s; s:=1;
end;
writeln(p);
end.
输入n求n的阶乘和
program sum1(input,output);
const max=10000;
var i,j,n : integer;
sum,fac : array[1..max+1] of integer;
begin
read(n);
for i := 1 to max do sum[i] := 0;
for i := 1 to max do fac[i] := 0;
fac[1] := 1;
for i := 1 to n do
begin
for j := 1 to max do fac[j] := fac[j]*i;
for j := 1 to max do
begin
fac[j+1] := fac[j+1]+fac[j] div 10;
fac[j] := fac[j] mod 10;
end;
for j := 1 to max do sum[j] := sum[j]+fac[j];
for j := 1 to max do
begin
sum[j+1] := sum[j+1]+sum[j] div 10;
sum[j] := sum[j] mod 10;
end;
end;
i := max;
while sum[i]=0 do i := i-1;
for j := i downto 1 do write(sum[j]);
writeln;
end.
uyty