How can i find factorial of 100! ?
Code:>> which data type can i use?. >> I didnt get answer even i used double,long double data type.
How can i find factorial of 100! ?
Code:>> which data type can i use?. >> I didnt get answer even i used double,long double data type.
the factorial of 100 or the factorial of 100!?
according to my calculator, the factorial of 100 is 9.33x10^157, which requires an unsigned integer of 525 bits (66 bytes) to hold it
my calculator claims that the factorial of 100! is infinity
Last edited by ಠ_ಠ; 06-23-2009 at 11:30 PM.
╔╗╔══╦╗
║║║╔╗║║
║╚╣╚╝║╚╗
╚═╩══╩═╝
>> which data type can i use?.
There is no way you're going to fit that number into a standard data type. You could use a large array of bytes and treat it as a "big integer".
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Though ... post #2 gave you the answer so you don't need to do it anymore. It's 9.33x10^157.
- use your head to think about the problem in detail, rather than just writing the obvious for loop to do all the work
- use a bignum library like this -> The GNU MP Bignum Library
- write your own bignum functions sufficient to solve the problem.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"