

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
C++ Program to Find Factorial of Large Numbers
The following is an example to find the factorial.
Example
#include <iostream> using namespace std; int fact(unsigned long long int n) { if (n == 0 || n == 1) return 1; else return n * fact(n - 1); } int main() { unsigned long long int n; cout<<"Enter number : "; cin>>n; cout<< “\nThe factorial : “ << fact(n); return 0; }
Output
Enter number : 19 The factorial : 109641728
In the above program, we have declared a variabe with the following data type for large numbers.
unsigned long long int n;
The actual code is in fact() function as follows −
int fact(unsigned long long int n) { if (n == 0 || n == 1) return 1; else return n * fact(n - 1); }
In the main() function, a number is entered by the user and fact() is called. The factorial of entered number is printed.
cout<<"Enter number : "; cin>>n; cout<<fact(n);
- Related Questions & Answers
- Python program to find factorial of a large number
- Factorial of a large number
- C++ Program to Find Factorial
- Factorial of Large Number Using boost multiprecision Library
- Java Program to Find Factorial of a number
- C++ Program to add few large numbers
- 8085 program to find the factorial of a number
- 8086 program to find the factorial of a number
- C++ Program to Find Factorial of a Number using Iteration
- C++ Program to Find Factorial of a Number using Recursion
- Java Program to Find Factorial of a Number Using Recursion
- Find Last Digit of a^b for Large Numbers in C++
- C++ Program to Find Factorial of a Number using Dynamic Programming
- C++ program to find first digit in factorial of a number
- Program to find trailing zeros in factorial of n in C++?
Advertisements