Q 5.13 (Factorials) Factorials are used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Write an application that calculates the factorials of 1 through 20. Use type long. Display the results in tabular format. What difficulty might prevent you from calculating the factorial of 100?
Code:
#include < iostream>
using namespace std;
int main()
{
int result = 1;
for( int n = 1; n <= 5; n++ ) {
result *= n;
cout << "Factorial of\t" << n << "\tis\t" << result << endl;
}
//for pause
system("PAUSE") ;
return 0;
}