We have given a large number now we can easily find out the factorial of this large number using boost multiprevision Library.
Boost library has included a new multiprecision library in the current 1.53.0 release for C++ programmers who need more precision than 64 bits.
Examples:
Input : 100
Output : 933262154439441526816992388562667004-
907159682643816214685929638952175999-
932299156089414639761565182862536979-
208272237582511852109168640000000000-
00000000000000
Input :50
Output : 3041409320171337804361260816606476884-
4377641568960512000000000000
// CPP program to find factorial of large // number using boost library. #include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> using boost::multiprecision::cpp_int; using namespace std; cpp_int Factorial(int number) { cpp_int num = 1; for (int i = 1; i <= number; i++) num = num * i; return num; } int main() { int number = 100; cpp_int fact = Factorial(number); cout << fact << endl; return 0; } |
Output:-
933262154439441526816992388562667004-
907159682643816214685929638952175999-
932299156089414639761565182862536979-
208272237582511852109168640000000000-
00000000000000
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Generating large Fibonacci numbers using boost library
- Advanced C++ with boost library
- boost::split in C++ library
- Any datatype in C++ boost library
- C++ Boost String Algorithms Library
- boost::algorithm::none_of_equal() in C++ library
- boost::algorithm::one_of_equal() in C++ library
- boost::algorithm::all_of() in C++ library
- boost::algorithm::all_of_equal() in C++ library
- boost::algorithm::one_of() in C++ library
- boost::algorithm::is_sorted() in C++ library
- boost::algorithm::any_of_equal() in C++ library
- boost::algorithm::any_of() in C++ library
- boost::algorithm::none_of() in C++ library
- boost::algorithm::is_partitioned() in C++ library
- boost::algorithm::clamp() in C++ library
- boost::algorithm::equal() in C++ library
- Synchronous Chatting Application using C++ boost::asio
- Boost.Lexical_Cast in C++
- C++ boost::dynamic_bitset Class with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

