I think challenge here is not the Execution time, but the storage. 300 ! or 400! should generally go beyond the storage capabilities of long long ints in cpp. @ Rohit Saraf: Hence, I don't know if even tail recursion will ultimately be able to store the output. I think Rajesh Patidar's answer fits the bill well, in terms of storage.
On Sun, May 2, 2010 at 2:23 PM, vignesh radhakrishnan < [email protected]> wrote: > I agree with abhijith. But given some very large x for which i would have > to find factorial. > I would either > (i) use gmp in cpp or BigInteger or java if its not a lab exercise or an > interview > (ii) use simple brute multiplication algorithm. > The second approach requires > (a) The no. of digits in n! for making storage available > (b) The calculation itself which I would brute force > > References: > > http://inder-gnu.blogspot.com/2009/08/find-number-of-digits-in-factorial-of.html > > http://stackoverflow.com/questions/1113167/can-one-know-how-large-a-factorial-would-be-before-calculating-it > http://delphiforfun.org/programs/big_factorials.htm > > > > On 2 May 2010 13:59, Rohit Saraf <[email protected]> wrote: > >> google it... u will gt it >> >> i am on mobile... cannot explain now.. >> >> On 5/2/10, divya jain <[email protected]> wrote: >> > wat is tail recursion plz explan in detail >> > >> > On 2 May 2010 08:15, Rohit Saraf <[email protected]> wrote: >> > >> >> @divya use tail recursion and rest should be fine.. >> >> >> >> -- >> >> -------------------------------------------------- >> >> Rohit Saraf >> >> Second Year Undergraduate, >> >> Dept. of Computer Science and Engineering >> >> IIT Bombay >> >> http://www.cse.iitb.ac.in/~rohitfeb14<http://www.cse.iitb.ac.in/%7Erohitfeb14> >> <http://www.cse.iitb.ac.in/%7Erohitfeb14> >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups >> >> "Algorithm Geeks" group. >> >> To post to this group, send email to [email protected]. >> >> To unsubscribe from this group, send email to >> >> [email protected]<algogeeks%[email protected]> >> <algogeeks%[email protected]<algogeeks%[email protected]> >> > >> >> . >> >> For more options, visit this group at >> >> http://groups.google.com/group/algogeeks?hl=en. >> >> >> >> >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Algorithm Geeks" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]<algogeeks%[email protected]> >> . >> > For more options, visit this group at >> > http://groups.google.com/group/algogeeks?hl=en. >> > >> > >> >> >> -- >> -------------------------------------------------- >> Rohit Saraf >> Second Year Undergraduate, >> Dept. of Computer Science and Engineering >> IIT Bombay >> http://www.cse.iitb.ac.in/~rohitfeb14<http://www.cse.iitb.ac.in/%7Erohitfeb14> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<algogeeks%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > There are two kinds of people. Those who care for others and The others > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
