Big Integer in C++ | Sololearn: Learn to code for FREE!

+5

Big Integer in C++

Look what I found! No more hastle of calculation of factorials of numbers > 100. #include <boost/multiprecision/cpp_int.hpp> #include <iostream> namespace mp = boost::multiprecision; using namespace std; int main() { mp::cpp_int u = 1; for(int i = 1; i <= 100; i++) u *= i; cout << "100! = " << u << '\n'; mp::cpp_int v = u / 100; cout << "99! = " << v << '\n'; }

1/10/2018 2:21:42 AM

Aditya

3 Answers

New Answer

+10

I found this in a pdf a while back which you may find interesting. (link to pdf in code). BigInt with native cpp/STL Boost library is better though imo. The pdf this is from is just a case study. https://code.sololearn.com/c0U2BqoJSrO1/?ref=app

+9

the boost library is indeed useful for many things

+6

If anyone is wondering. https://www.boost.org/