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@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
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor