Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4) The factorial of a nonnegative integer n is written n! (pronounced \"n factor

ID: 3616833 • Letter: 4

Question

 4) The factorial of a nonnegative integer n is written     n! (pronounced "n factorial") and
is defined as follows:

n! = n * (n-1) * (n-2) * ... * 1
0! = 1 and 1! = 1 by definition.

For example, 5! = 5*4*3*2*1 = 120

a) Write a program that reads a nonnegative integer and computes and prints its factorial.
Do not use scientific notation for displaying the result.

b) Write a program that estimates the value of mathematical constant e by using the formula:

e = 1 + (1/1!) + (1/2!) + (1/3!) ...

Prompt the user for the desired accuracy of e, i.e. the number of terms in the summation.
Use 10 digits of precision to display the result.


Expected sample output:

Number for Factorial : 16
16! = 20922789888000.000000
Desired Accuracy for "e"(number of terms in the series) : 10
e with 10 terms = 2.7182815256 (with 10 digits of accuracy)

Explanation / Answer

please rate-thanks #include double factorial(double); int main() {     double n;     coutn;     cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote