45 lines
1.4 KiB
Text
45 lines
1.4 KiB
Text
include xpllib; \for Big ops
|
|
def Size = 36000;
|
|
|
|
func BigSize(Num); \Return number of digits in a big number
|
|
char Num;
|
|
int I;
|
|
[for I:= 0 to Size-1 do
|
|
if Num(I) # ^0 then return Size-I;
|
|
return Size;
|
|
];
|
|
|
|
char LFact(Size+1), Sum(Size+1), BigI(Size+1);
|
|
int I;
|
|
[Int2Big(1, LFact, Size); \LFact:= 1
|
|
Int2Big(0, Sum, Size); \Sum:= 0
|
|
BigOut(0, Sum); CrLf(0);
|
|
for I:= 1 to 10 do
|
|
[BigAdd(Sum, LFact); \Sum:= Sum + LFact
|
|
BigOut(0, Sum); CrLf(0);
|
|
Int2Big(I, BigI, Size);
|
|
BigMul(LFact, BigI); \LFact:= LFact*I
|
|
];
|
|
CrLf(0);
|
|
Int2Big(1, LFact, Size); \LFact:= 1
|
|
Int2Big(0, Sum, Size); \Sum:= 0
|
|
for I:= 1 to 110 do
|
|
[BigAdd(Sum, LFact); \Sum:= Sum + LFact
|
|
if I >= 20 and rem(I/10) = 0 then
|
|
[ChOut(0, ^!); IntOut(0, I); Text(0, " = ");
|
|
BigOut(0, Sum); CrLf(0)];
|
|
Int2Big(I, BigI, Size);
|
|
BigMul(LFact, BigI); \LFact:= LFact*I
|
|
];
|
|
CrLf(0);
|
|
Int2Big(1, LFact, Size); \LFact:= 1
|
|
Int2Big(0, Sum, Size); \Sum:= 0
|
|
for I:= 1 to 10_000 do
|
|
[BigAdd(Sum, LFact); \Sum:= Sum + LFact
|
|
if I >= 1000 and rem(I/1000) = 0 then
|
|
[ChOut(0, ^!); IntOut(0, I); Text(0, " -> ");
|
|
IntOut(0, BigSize(Sum)); CrLf(0)];
|
|
Int2Big(I, BigI, Size);
|
|
BigMul(LFact, BigI); \LFact:= LFact*I
|
|
];
|
|
]
|