Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Factorial record ?

1 view
Skip to first unread message

Joël Bourquard

unread,
Jan 24, 2002, 9:42:14 AM1/24/02
to
Hi,

I'd like to know if someone is aware of a record in factorial calculations
resulting in huge numbers (1000! and above)

Two years ago I have built a very fast algorithm, which can compute huge
factorial results, and would like if a record is established.

Thanks in advance !

Joėl


Dave Seaman

unread,
Jan 24, 2002, 10:49:15 AM1/24/02
to
In article <3c501d1d$1...@news.deckpoint.ch>,
Joėl Bourquard <j...@esecurium.com.nospam> wrote:

>I'd like to know if someone is aware of a record in factorial calculations
>resulting in huge numbers (1000! and above)

>Two years ago I have built a very fast algorithm, which can compute huge
>factorial results, and would like if a record is established.

1000! takes longer to print than it does to compute, using Mathematica on
my Mac. It begins printing almost instantaneously, but takes a couple
seconds to finish. Surely a record computation should at least keep the
computer busy long enough for you to get a cup of coffee.

--
Dave Seaman dse...@purdue.edu
Amnesty International says Mumia Abu-Jamal decision falls short of justice.
<http://www.amnestyusa.org/news/2001/usa12192001.html>

Carl W.

unread,
Jan 24, 2002, 11:12:13 AM1/24/02
to
"Dave Seaman" wrote:

> Joël Bourquard <j...@esecurium.com.nospam> wrote:
>
> >I'd like to know if someone is aware of a record in factorial
calculations
> >resulting in huge numbers (1000! and above)
>
> >Two years ago I have built a very fast algorithm, which can compute huge
> >factorial results, and would like if a record is established.
>
> 1000! takes longer to print than it does to compute, using Mathematica on
> my Mac. It begins printing almost instantaneously, but takes a couple
> seconds to finish. Surely a record computation should at least keep the
> computer busy long enough for you to get a cup of coffee.

I was going to post something similar, except I used bc on a Linux box.

I've just had it calculate 1000000! using sums of logs (therefore it's a bit
of an approximation), with no optimisations whatsoever. It took ~45 mins (I
was having a coffee so I didn't notice it finish :) ).

This code:

scale=10;t=0;for(i=1;i<=1000000;i++)t+=l(i);t/=l(10);it=int(t);t=power(10,t-
it);print t,"e+",it,"\n"

returned this:

8.2678449060e+5565708

Can someone confirm the accuracy of this?

*** Of course all of this tomfoolery is academic. A decent
Gamma-approximator should return any factorial in no time at all...

Carl

PS ICYWW int() and power() aren't standard bc. I've had to write them.
Anyone know of a place where I can get bc libraries?


David C. Ullrich

unread,
Jan 24, 2002, 11:53:57 AM1/24/02
to
On 24 Jan 2002 10:49:15 -0500, dse...@seaman.cc.purdue.edu (Dave
Seaman) wrote:

>In article <3c501d1d$1...@news.deckpoint.ch>,


>Joël Bourquard <j...@esecurium.com.nospam> wrote:
>
>>I'd like to know if someone is aware of a record in factorial calculations
>>resulting in huge numbers (1000! and above)
>
>>Two years ago I have built a very fast algorithm, which can compute huge
>>factorial results, and would like if a record is established.
>
>1000! takes longer to print than it does to compute, using Mathematica on
>my Mac. It begins printing almost instantaneously, but takes a couple
>seconds to finish. Surely a record computation should at least keep the
>computer busy long enough for you to get a cup of coffee.

Heck, I can compute it instantaneously (and see the first ten digits)
if I compute 1000! recursively in _Python_, which seems like a pretty
slow way to do it.

(Didn't try to print it all in the Windows Python thingie I use...
I can also save the whole thing to a file instantaneously. Then
it turns out that my favorite text editor tends to crash the system
if I try to open a file containing a line more than a few thousand
characters long...)

>--
>Dave Seaman dse...@purdue.edu
>Amnesty International says Mumia Abu-Jamal decision falls short of justice.
><http://www.amnestyusa.org/news/2001/usa12192001.html>


David C. Ullrich

Flip Flippy

unread,
Jan 24, 2002, 12:02:09 PM1/24/02
to
"Carl W." <ro...@127spam.0.0.1> wrote in message
news:3c503...@katana.legend.co.uk...
> I've just had it calculate 1000000! returned this:

> 8.2678449060e+5565708
>
> Can someone confirm the accuracy of this?

You can use Stirling's approximation, but a better one is Gosper's
(number 3. below):
1. n! ~= (n^n)e^(-n) =
3.296831473779587525702*10^5565705
2. n! ~= sqrt(2 Pi)*n^(n+1/2)e^(-n) =
8.263930996566422941576402*10^5565708
3. n! ~= sqrt[(2n + 1/3)*Pi]*(n^n)*(e^(-n)) = (
8.263931677530192504846745*10^5565708

That is, your approximation is pretty good!

Also, you could use an exact symbolic calculator like mathematica
(on my PIII w/WNT), this took 7 minutes (too ... too long to post)!

HTH, Flip


--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

Gerry Myerson

unread,
Jan 24, 2002, 6:27:35 PM1/24/02
to
In article <3c501d1d$1...@news.deckpoint.ch>, "Joėl Bourquard"
<j...@esecurium.com.nospam> wrote:

> I'd like to know if someone is aware of a record in factorial calculations
> resulting in huge numbers (1000! and above)

Once upon a time - back in the 1950s, maybe a bit earlier - there was
a journal called Scripta Mathematica which actually published stuff
like this - all the digits of n-factorial, for values of n large enough
for the answer to take up several pages in the journal.

They published some useful stuff, too, but what I remember is
the pages full of digits.

Gerry Myerson (ge...@mpce.mq.edu.au)

David W. Cantrell

unread,
Jan 25, 2002, 12:53:54 AM1/25/02
to
"Flip Flippy" <fl...@safebunch.com> wrote:
> "Carl W." <ro...@127spam.0.0.1> wrote in message
> news:3c503...@katana.legend.co.uk...
> > I've just had it calculate 1000000! returned this:
> > 8.2678449060e+5565708
> >
> > Can someone confirm the accuracy of this?
>
> You can use Stirling's approximation, but a better one is Gosper's
> (number 3. below):
> 1. n! ~= (n^n)e^(-n) =
> 3.296831473779587525702*10^5565705
> 2. n! ~= sqrt(2 Pi)*n^(n+1/2)e^(-n) =
> 8.263930996566422941576402*10^5565708
> 3. n! ~= sqrt[(2n + 1/3)*Pi]*(n^n)*(e^(-n)) = (
> 8.263931677530192504846745*10^5565708

??? You're not doing justice to Gosper's approximation. In fact it gives
8.26393168833118*10^5565708, getting the 13 most significant digits of
(10^6)! correct. Can anyone here give me more information about Gosper's
approximation?

If you want a more accurate approximation, you can use a portion of my
new convergent expansion for the gamma function as given at
<http://mathforum.org/epigone/sci.math.num-analysis/zonchahee>.
In fact, if you completely ignore the continued fraction (called CF there),
you get that n! is approx.

Sqrt(2*Pi)*((n+1/2)/e)^(n+1/2)*(48*n+23)/(48*n+25)

Using n = 10^6 this gives an approximation of which the 20 most significant
digits are correct: 8.2639316883312400623565*10^5565708, as compared with
precisely (10^6)! = 8.2639316883312400623766...*10^5565708 .

David W. Cantrell

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service

Joël Bourquard

unread,
Jan 25, 2002, 4:14:30 AM1/25/02
to
Hi,

I should have said, I was not meaning approximations, but Integer answers..
For example, I did 1,000,000 ! :-)

The result is then stored in base 16... For 1000000! it makes a 4+ megabyte
file.

Note: 1000! takes long to display in Mathematica, because of the radix
conversion (base 2^n => base10).

Joėl

"Carl W." <ro...@127spam.0.0.1> wrote in message
news:3c503...@katana.legend.co.uk...

> "Dave Seaman" wrote:

Pongo

unread,
Jan 25, 2002, 6:10:02 AM1/25/02
to
Gerry Myerson <ge...@mpce.mq.edu.au> wrote in message news:<gerry-584DA0.09273525012002@[137.111.1.11]>...

And there was Dan Shanks' Unpublished Mathematical Tables at
Mathematics of Computation. I wonder if the UMT is still around...

Pongo

0 new messages