procedure InitLongNumber(n: longint; var a: longnum); var i: longint; begin for i := 1 to len do if n <> 0 then begin a[i] := n mod 10; n := n div 10 end else a[i] := 0; end;
function mul(a: longnum; k: longint): longnum; var i, tmp: longint; begin tmp := 0;
for i := 1 to len - 1 do begin a[i] := a[i] * k + tmp; tmp := a[i] div 10; a[i] := a[i] mod 10 end;
result := a end;
procedure PrintLongNumber(a: longnum); var i, j: longint; begin i := len; while a[i] = 0 do dec(i); for j := i downto 1 do write(a[j]) end;
begin readln(n); InitLongNumber(1, s); for i := 1 to n do s := mul(s, i); write(n, '! = '); PrintLongNumber(s); end.
uses System.Numerics; var n,i:integer; begin Write('Введите натуральное число: '); Read(n); var f:=new BigInteger(1); for i:=2 to n do f:=f*i; Writeln(n,'! = ',f); end.
type
longnum = array[1..len] of longint;
var
n, i: longint;
s: longnum;
procedure InitLongNumber(n: longint; var a: longnum);
var
i: longint;
begin
for i := 1 to len do
if n <> 0 then
begin
a[i] := n mod 10;
n := n div 10
end else
a[i] := 0;
end;
function mul(a: longnum; k: longint): longnum;
var
i, tmp: longint;
begin
tmp := 0;
for i := 1 to len - 1 do
begin
a[i] := a[i] * k + tmp;
tmp := a[i] div 10;
a[i] := a[i] mod 10
end;
result := a
end;
procedure PrintLongNumber(a: longnum);
var
i, j: longint;
begin
i := len;
while a[i] = 0 do
dec(i);
for j := i downto 1 do
write(a[j])
end;
begin
readln(n);
InitLongNumber(1, s);
for i := 1 to n do
s := mul(s, i);
write(n, '! = ');
PrintLongNumber(s);
end.
uses System.Numerics;
var
n,i:integer;
begin
Write('Введите натуральное число: '); Read(n);
var f:=new BigInteger(1);
for i:=2 to n do f:=f*i;
Writeln(n,'! = ',f);
end.
Тестовое решение:
Введите натуральное число: 50
50! = 30414093201713378043612608166064768844377641568960512000000000000