Re: factorial of very big number like 4096



Keith Thompson a écrit :
Richard Heathfield <invalid@xxxxxxxxxxxxxxx> writes:

Chris Dollin said:

[...]

There are libraries out there that do unbounded-precision arithmetic,
yes.

No, there aren't, for any reasonable definition of "unbounded".


There are libraries that do arithmetic on quantities whose magnitude
is limited only by available memory.

I won't claim that that's a reasonable definition of "unbounded", but
it's good enough for many applications that don't *really* need
unbounded magnitudes.


Using a relatively small amount of memory for the numbers
in a PC, i.e. 1GB numbers. Supposing 8GB main RAM,
and 16GB swap that would work. You would hold
up to 3 or 4 numbers in core RAM, enough for the
four operations and some intermeidate storage.

We have then numbers of :

1 073 741 824 bytes, i.e. 8 589 934 592 bits.

Dividing by 3 this means (in decimal) numbers of
2 863 311 530 digits, what could be enough for
many applications.

:-)


In a more reasonable realm, 1MB numbers hold 8 388 608
bits or 2 796 202 decimal digits. With a run of the mill
PC with 1GB RAM we can hold several of those numbers
in RAM. No problems!

Not unbounded of course, but the bounds are fairly large
.