Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make sure its in C Resler's Notes: 1. Remember that one can calculate the factorial of x (x!) using the following equation: x! = 1
Make sure its in C
Resler's Notes: 1. Remember that one can calculate the factorial of x (x!) using the following equation: x! = 1 x 2 x...x (x - 1) xr Write a C program that inputs a positive value for r and then com- putes and prints x! You will need to use a loop that performs one multiplication in the series of multiplications per loop iteration. Note what changes in the equation above - is there a series of values needed? Your loop con- trol variable should produce this series, one value per loop iteration. Also note that x! = r * (x - 1)!. The value (x - 1)! will represent the computed value of factorial for the previous loop iteration. So to compute each value per loop iteration you would write fact = fact * n where n is the current value in the series of 1...x. What will you need to initialize fact to in order for this to work? 2. The value of the mathematical constant e can be expressed as the infinite series e=1+1/1! +1/2! +1/3! + ... Write a complete C program that approximates e by computing the value of 1+1/1! +1/2+1/3! + ... +1! where n is an integer greater than 2 entered by the user. (Hint: you will need to write two loops, one nested inside the other. The inner loop will compute each factorial value as in question #1 above, and the outer loop will step you through the values 1 to n.)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started