Even the straightforward factorial function required a fixed number of
steps which is O(n!). Caching previous results is a significant
optimization, but it would mean being able to store say n! for all n <
321. Then compute n! as n * (n-1)!. But even then it is asymptotically
the same running time
yeah, I think approximation is the way to go.Striling's approximation gives you upper and lower bounds on factorials. and these are very tight bounds.And the best thing about approximations is, they require a fixed no of operations.
On 5/3/06, BiGYaN <[EMAIL PROTECTED]> wrote:
To get the factorial
To get the factorial exactly, you'd surely have to multiply and find
out.
But no.s like 321! are too big to be used with all the digits. So you
can use one of the many very good approximation methods to find it out.
--~--~-~--~~~---~--~~
You received this message
> Hi everybody
>
>
> I am in need to find factorial of numbers .
...
> Is there any other algorithm which requires less amount of processing .and
> finds the factorial of any bigger number in simple way.
>
If you can do with an approximation, there is always Stirlings's
approximation.
--~
well to find the factorial of very large numbers u can use linkedlist
or some other datastructure to hold the digits of the product and
manipulate the linked list..because the size of the linked list can
grow at runtime. I guess this will solve ur problem...
u need a linked list because the si
On 5/2/06, Thati ravi <[EMAIL PROTECTED]> wrote:
[...]
> But if I have to find factorial of 200 ,321, or bigger numbers like
> thiswhat should i do .. the algorithm requires somany CPU cycles for
> this kinda numbers.
well ... the first (and ok, maybe stupid) question is: are you sure that
what u think? is it better to find them in powers of prime nos andthen
calculate it . i m not sure wheather this would suffice. still we can
take this disscussion
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Alg