Author |
Topic: 100! (Read 950 times) |
|
sat90
Newbie


Posts: 7
|
whats the logic behind calculating 100!......w/o using any bigint lib
|
|
IP Logged |
|
|
|
SMQ
wu::riddles Moderator Uberpuzzler
    

Gender: 
Posts: 2084
|
 |
Re: 100!
« Reply #1 on: Aug 15th, 2011, 9:19am » |
Quote Modify
|
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
|
|
IP Logged |
--SMQ
|
|
|
towr
wu::riddles Moderator Uberpuzzler
    
 Some people are average, some are just mean.
Gender: 
Posts: 13730
|
 |
Re: 100!
« Reply #2 on: Aug 15th, 2011, 1:14pm » |
Quote Modify
|
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.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
    

Gender: 
Posts: 7527
|
 |
Re: 100!
« Reply #3 on: Aug 22nd, 2011, 5:07am » |
Quote Modify
|
Or you can apply the method you learned at school. With a pencil, paper and lots of time. 100! should still be feasible.
|
|
IP Logged |
|
|
|
sat90
Newbie


Posts: 7
|
 |
Re: 100!
« Reply #5 on: Sep 5th, 2011, 6:10am » |
Quote Modify
|
i m not able to simulate manual multiplication using algorithm...plz help!!
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
    
 Some people are average, some are just mean.
Gender: 
Posts: 13730
|
 |
Re: 100!
« Reply #6 on: Sep 5th, 2011, 8:49am » |
Quote Modify
|
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]; |
|
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
|