// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and // distribute this software is granted provided this copyright notice appears // in all copies. This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // Modified to show all factorial up to 40, Paul A Bristow, Oct 2002 // also works OK using cout << hex #include "boost/bigint.hpp" #include #include using std::cout; using std::endl; using std::hex; using std::dec; int main() { // 40 factorial = 40! boost::bigint value(1); for(int i = 1; i <= 40; ++i) { value *= i; cout << dec << i << "! = " << value << endl; } value = 1; for(int i = 1; i <= 40; ++i) { value *= i; cout << hex << i << "! = " << value << endl; } return 0; } // int main() /* 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880 10! = 3628800 11! = 39916800 12! = 479001600 13! = 6227020800 14! = 87178291200 15! = 1307674368000 16! = 20922789888000 17! = 355687428096000 18! = 6402373705728000 19! = 121645100408832000 20! = 2432902008176640000 21! = 51090942171709440000 22! = 1124000727777607680000 23! = 25852016738884976640000 24! = 620448401733239439360000 25! = 15511210043330985984000000 26! = 403291461126605635584000000 27! = 10888869450418352160768000000 28! = 304888344611713860501504000000 29! = 8841761993739701954543616000000 30! = 265252859812191058636308480000000 31! = 8222838654177922817725562880000000 32! = 263130836933693530167218012160000000 33! = 8683317618811886495518194401280000000 34! = 295232799039604140847618609643520000000 35! = 10333147966386144929666651337523200000000 36! = 371993326789901217467999448150835200000000 37! = 13763753091226345046315979581580902400000000 38! = 523022617466601111760007224100074291200000000 39! = 20397882081197443358640281739902897356800000000 40! = 815915283247897734345611269596115894272000000000 Press any key to continue 1! = 1 2! = 2 3! = 6 4! = 18 5! = 78 6! = 2d0 7! = 13b0 8! = 40140 9! = 240b40 a! = 16a2260 b! = f971a90 c! = 41edc0640 d! = 3e0a8e0320 e! = 3671e9504b0 f! = 10c041d0c1f40 10! = 14240b231c1f40 11! = 1631ada0af91770 12! = 19020e99023c1f40 13! = c066d03ec037307d0 14! = f30b5600511df00000 15! = 13f503ae06b503b00000 16! = b096002d71e6003000000 17! = 10214511a5222911df00000 18! = 183c12e806c5095a0f600000 19! = f13f803ec0d02268320d00000 1a! = 1930b6217e019cd18d320d00000 1b! = 1037821f613b120a006471a900000 1c! = 1e13180d7604930f14139701900000 1d! = 37406e126d10f8207a2153c06400000 1e! = 2197d0b2b1fb9239121bc0c0c1f400000 1f! = 5208eb21ce06f308e91e2d15fc1f400000 20! = a470c0b1b151b170bc81c32007917700000 21! = 81ab106e1226b22a0254f20020fac1f400000 22! = 127091726af25840580129921a1192307d00000 23! = 1014d05c719ee180024501a090539147000000000 24! = 2507c90cc3231e04c1124726d81fd620a000000000 25! = 5600ea903900a4a13b60c571f16062c234000000000 26! = 508fe0a39123a006f06e00048096a004a0b6000000000 27! = cb263c082107b610ef21c00b010f960b510df000000000 28! = 1fdf05f80caf23110d6a15eb0a87258b17060aa000000000 Press any key to continue */