Tuesday 21 July 2020

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?

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;
forint 1<= 5n++ ) {
result *n;
cout << "Factorial of\t<< << "\tis\t<< result << endl;
}
//for pause
system("PAUSE";
return 0;
}

No comments:

Post a Comment