Re: [algogeeks] 400!

2010-05-13 Thread Yalla Sridhar
python int has no bounds, it can scale upto the mem u have available on your computer. On Thu, May 13, 2010 at 7:53 AM, Nikhil Agarwal nikhil.bhoja...@gmail.comwrote: @jitendra: your python code is awesome and it works.:) On Wed, May 12, 2010 at 6:37 PM, divya jain

Re: [algogeeks] 400!

2010-05-12 Thread divya jain
thanx to all 4 the solutions.. On 3 May 2010 18:39, Varun Nagpal varun.nagp...@gmail.com wrote: @Rajesh gave a simple elegant solution. A look at a Linux calculator : you can even calculate 99! = 8.854887824e+5584950 in few seconds. I just looked at the code(its open source right!),

Re: [algogeeks] 400!

2010-05-12 Thread Nikhil Agarwal
@jitendra: your python code is awesome and it works.:) On Wed, May 12, 2010 at 6:37 PM, divya jain sweetdivya@gmail.comwrote: thanx to all 4 the solutions.. On 3 May 2010 18:39, Varun Nagpal varun.nagp...@gmail.com wrote: @Rajesh gave a simple elegant solution. A look at a Linux

Re: [algogeeks] 400!

2010-05-03 Thread siddharth srivastava
But is there any way to accomplish this without an array ? Even for 100!. On 2 May 2010 06:15, Prasoon Mishra prasoonbluel...@gmail.com wrote: 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

Re: [algogeeks] 400!

2010-05-03 Thread Rohit Saraf
are forget abt representation. It can be stored as string anyways. Tail recursion is awesome at times ! -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Mon,

Re: [algogeeks] 400!

2010-05-03 Thread Jitendra Kushwaha
You can do it easily in python...:) Here is the python code n=400 def fact(num): ans = 1 while(num): ans = ans*num num = num-1 return ans print fact(n) #printing 400! even 1000! can be calculated Regards Jitendra Kushwaha Undergradute Student Computer Science

Re: [algogeeks] 400!

2010-05-03 Thread divya jain
nice algo by rajesh. bt i think using linked list will be better.. On 3 May 2010 09:46, siddharth srivastava akssps...@gmail.com wrote: But is there any way to accomplish this without an array ? Even for 100!. On 2 May 2010 06:15, Prasoon Mishra prasoonbluel...@gmail.com wrote: I think

Re: [algogeeks] 400!

2010-05-03 Thread vignesh radhakrishnan
@siddharth and prasoon either design a very long integer library yourself, or use gmp library in cpp or BigInteger Class in java. Regards, vignesh On 3 May 2010 09:46, siddharth srivastava akssps...@gmail.com wrote: But is there any way to accomplish this without an array ? Even for 100!.

Re: [algogeeks] 400!

2010-05-03 Thread Rajesh Patidar
you have to store the result some where for that you don't have inbuilt datatype like python those will take care of your overflow On Mon, May 3, 2010 at 9:46 AM, siddharth srivastava akssps...@gmail.com wrote: But is there any way to accomplish this without an array ? Even for 100!. On 2 May

Re: [algogeeks] 400!

2010-05-03 Thread Anil C R
@Jitendra but that's no fun [?] - Anil On Mon, May 3, 2010 at 5:12 PM, vignesh radhakrishnan rvignesh1...@gmail.com wrote: @siddharth and prasoon either design a very long integer library yourself, or use gmp library in cpp or BigInteger Class in java. Regards, vignesh On 3 May

Re: [algogeeks] 400!

2010-05-03 Thread Varun Nagpal
@Rajesh gave a simple elegant solution. A look at a Linux calculator : you can even calculate 99! = 8.854887824e+5584950 in few seconds. I just looked at the code(its open source right!), which is not so easy to understand in few minutes. Here is the some part of code I extracted from

Re: [algogeeks] 400!

2010-05-03 Thread Rajesh Patidar
ya string one even will be more suitable way.. On Mon, May 3, 2010 at 5:33 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: are forget abt representation. It can be stored as string anyways. Tail recursion is awesome at times ! -- Rohit Saraf

Re: [algogeeks] 400!

2010-05-02 Thread divya jain
wat is tail recursion plz explan in detail On 2 May 2010 08:15, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @divya use tail recursion and rest should be fine.. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and

Re: [algogeeks] 400!

2010-05-02 Thread Rohit Saraf
google it... u will gt it i am on mobile... cannot explain now.. On 5/2/10, divya jain sweetdivya@gmail.com wrote: wat is tail recursion plz explan in detail On 2 May 2010 08:15, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @divya use tail recursion and rest should be fine.. --

Re: [algogeeks] 400!

2010-05-02 Thread vignesh radhakrishnan
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

Re: [algogeeks] 400!

2010-05-02 Thread Prasoon Mishra
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

[algogeeks] 400!

2010-05-01 Thread divya
give an algo to calculate 300! or even 400! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] 400!

2010-05-01 Thread Rajesh Patidar
take an long array of integer (to store the answer) let Mod=1 (maximum allowable size or number in the array element initialize the last element of array with 1 and know start multiplying the 1--n into the last number to first of array if any number crosses the given then take m=a[i]/mod and