For any integer n > 0, n!(n factorial) is defined as the product n *...
50.1K
Verified Solution
Link Copied!
Question
Accounting
For any integer n > 0, n!(n factorial) is defined as the product
n * n - 1 * n 2 ... * 2 * 1. It is sometimes useful to have a closed-form definition instead; for this purpose, an approximation can be
And 0! is defined to be 1. used. R.W. Gosper proposed the following approximation formula:
a) Create a function takes n as input and returns the approximation for factorial value back.
b) Create another function takes n as input and computes then returns the accurate value for n!=
n * n - 1 * n 2 ... * 2 * 1.
c) Your program should prompt the user to enter an integer n, call both functions to compute the approximate and accurate values for n! and then display the results. The message displaying the result should look something like this:
5! equals approximately 119.97003 5! is 120 accurately.
d) Test the program on nonnegative integers less than 8, and also on integers greater than 8. At what value does the approximation fail to generate accurate results? Generate a message that reports if the approximation is not valid anymore.Use the percent error formula to find if the approximation value is accurate.
TIP: Be careful with the type conversions. Be sure to use a named constant for PI, and use the approximation 3.14159265.
percent error
Answer & Explanation
Solved by verified expert
Get Answers to Unlimited Questions
Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!
Membership Benefits:
Unlimited Question Access with detailed Answers
Zin AI - 3 Million Words
10 Dall-E 3 Images
20 Plot Generations
Conversation with Dialogue Memory
No Ads, Ever!
Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!