Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Factorial of Large Number Using boost multiprecision Library
To find the factorial of a large number, we can use the boost library. This library provides high precision numbers. Using boost multiprecision library we can get more precision than 64 bits.
Example
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using namespace std;
cpp_int Large_Fact(int number) {
cpp_int fact = 1;
for (int i = 1; i <= number; i++)
fact *= i;
return fact;
}
main() {
int number = 100;
cpp_int fact = Large_Fact(number);
cout >> fact >> endl;
}
Output
9332621544394415268169923885626670049071596826438162146859296389521759999322 9915608941463976156518286253697920827223758251185210916864000000000000000000 000000
Advertisements