Cpp Examples Factorial
# C++ Example - Calculate the Factorial of a Number
[ C++ Examples](#)
The factorial of a positive integer (English: factorial) is the product of all positive integers less than or equal to that number, and the factorial of 0 is 1. The factorial of a natural number n is written as n!.
## Example
#includeusing namespace std; int main(){unsigned int n; unsigned long long factorial = 1; cout<>n; for(int i = 1; i<=n; ++i){factorial *= i; }cout<<n<<"! = "<<factorial; return 0; }
The output of the above program is:
Enter an integer: 1212! = 479001600
[ C++ Examples](#)
YouTip