Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

we have to do it in C language 2. For any integer n > 0, n! is defined as the product n (n - 1)

image text in transcribedwe have to do it in C language

2. 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! = n^n x e^(-n) x square_root((2n + 1/3) x pi) Create a function that prompts the user to enter an integer n uses Gosper's formula to approximate n!, and then displays the result. The input data should be read and output result should be printed in the main function, and the calculation should be in the function for Problem 2. The message displaying the result should look something like this: Enter a number: 5 5! equals approximately 119.97003 Your program will be easier to debug if you use some intermediate values instead of trying to compute the result in a single expression. If you are not getting the correct results, then you can compare the results of your intermediate values to what you get when you do the calculations by hand. Use at least two intermediate variables - one for 2n + 1/3 and one for (2n + 1/3) x pi. Display each of these intermediate values to simplify debugging. Be sure to use a named constant for PI, and use the approximation 3.14159265 and use a constant for E, approximated as 2.718281827. Test the program on nonnegative integers less than 8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions