fork download
  1. #include <boost/multiprecision/cpp_int.hpp>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. using namespace boost::multiprecision;
  7.  
  8. int128_t v = 1;
  9.  
  10. // Do some fixed precision arithmetic:
  11. for(unsigned i = 1; i <= 20; ++i)
  12. v *= i;
  13.  
  14. std::cout << v << std::endl; // prints 20!
  15.  
  16. // Repeat at arbitrary precision:
  17. cpp_int u = 1;
  18. for(unsigned i = 1; i <= 100; ++i)
  19. u *= i;
  20.  
  21. std::cout << u << std::endl; // prints 100!
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 15296KB
stdin
Standard input is empty
stdout
2432902008176640000
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000