C PROGRAMMING LANGUAGE **Please provide comments. **you ll notice that Euler's number is involved. The math library has a special built in function that uses Euler's number for the calculation. Please use that instead of defining a constant e value.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

C PROGRAMMING LANGUAGE 

 

**Please provide comments.

 

**you ll notice that Euler's number is involved. The math library has a special built in function that uses Euler's number for the calculation. Please use that instead of defining a constant e value.

Question 4) For any integer n> 0, n! is defined as the product n * n – 1 * n – 2 .. * 2 * 1! is
defined to be 1. It is sometimes useful to have a closed-form definition instead; for this purpose,
an approximation can be used. R.W. Gosper proposed the following such approximation
formula:
n! z n"e-n
2n +
Create a program that prompts the user to enter an integer n, uses Gosper's formula to
approximate n!, and then displays the result. The message displaying the result should look
something like this:
Enter a value for
5! equals approximately 119.97003
5
For this problem, define a user defined function that performs the calculation. The user defined
function takes one argument of type int and will return the result of the computation of type
double to display. Name the user defined function FactorialApprox. Define a constant
macro called PI and set it to 3.14159265
Transcribed Image Text:Question 4) For any integer n> 0, n! is defined as the product n * n – 1 * n – 2 .. * 2 * 1! is defined to be 1. It is sometimes useful to have a closed-form definition instead; for this purpose, an approximation can be used. R.W. Gosper proposed the following such approximation formula: n! z n"e-n 2n + Create a program that prompts the user to enter an integer n, uses Gosper's formula to approximate n!, and then displays the result. The message displaying the result should look something like this: Enter a value for 5! equals approximately 119.97003 5 For this problem, define a user defined function that performs the calculation. The user defined function takes one argument of type int and will return the result of the computation of type double to display. Name the user defined function FactorialApprox. Define a constant macro called PI and set it to 3.14159265
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr