[Tutor] how to handle big numbers
surya k
suryak at live.com
Fri Dec 9 21:04:39 CET 2011
----------------------------------------
> Date: Fri, 9 Dec 2011 14:53:07 -0500
> From: d at davea.name
> To: suryak at live.com
> CC: tutor at python.org
> Subject: Re: [Tutor] how to handle big numbers
>
> On 12/09/2011 02:25 PM, surya k wrote:
> > Finding factorial of 8 or 9 isn't big. If I would like to find factorial of 32327, how can I ??
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> How close do you want your answer? The gamma function can be used to
> calculate it, but it won't be precise. I don't know how many digits
> are in 32327!, but it must be at least hundreds of thousands, and a
> float cannot represent that exactly. In fact it cannot represent a
> number that big, even approximately. It might be millions of digits,
> but I don't have the time right now to figure it out.
>
> If you use a long int (which int will promote to, automatically), you
> could do the calculation with a very simple program, providing you don't
> run out of either time or memory.
>
> if it were my problem, I'd do it in three steps. First write a program
> to calculate N! exactly. See how long it takes for 100, and how many
> digits are in the answer. Then try it again for 1000!
>
> Next, I'd look up the gamma function, and figure out how large the
> desired value will be.
>
> Finally, depending on what I got from those first two, I'd either run
> the first program with 32327, and wait a long time, or write a
> specialized math package to calculate the gamma function to whatever
> precision I thought Ineeded.
>
>
> --
>
> DaveA
>
Well, its in a puzzle.. everything is done except this part. I need to calculate N! ( max value of N is 10^6).
More information about the Tutor
mailing list