wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> 100!
(Message started by: sat90 on Aug 14th, 2011, 12:05pm)

Title: 100!
Post by sat90 on Aug 14th, 2011, 12:05pm
whats the logic behind calculating 100!......w/o using any bigint lib

Title: Re: 100!
Post by SMQ on Aug 15th, 2011, 9:19am
Since 100! has 158 (decimal) digits, you're going to be hard-pressed to calculate the exact result without an arbitrary-precision math library of some sort.  However you can, for instance, count the number of zeros at the end w/o a bigint library.

--SMQ

Title: Re: 100!
Post by towr on Aug 15th, 2011, 1:14pm
It's not that hard to implement the method of multiplication you learned in school. Although it's not very efficient, it'll get the job done.

Title: Re: 100!
Post by Grimbal on Aug 22nd, 2011, 5:07am
Or you can apply the method you learned at school.  With a pencil, paper and lots of time.
100! should still be feasible.

Title: Re: 100!
Post by towr on Aug 22nd, 2011, 8:43am
It's easy to make mistakes by hand, though.

Title: Re: 100!
Post by sat90 on Sep 5th, 2011, 6:10am
i m not able to simulate manual multiplication using algorithm...plz help!!

Title: Re: 100!
Post by towr on Sep 5th, 2011, 8:49am
Something like:

Pseudo
Code:
int A[200] = {0};
A[0]=1;
for(C=2; i <=100; i++)
{
 temp = 0;
 for(i=0; i < 200; i++)
 {
    temp +=  C * a[i];
    A[i] = temp % 10;
    temp /= 10;
 }
}

for(i=200; i > 0 && A[i] == 0; i--)
 ;

for(; i >=0; i--)
   cout << a[i];




Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board