Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a program to compute N! using unsigned integer type of array to store; for a N from 1 to 99,999,999. The result can

Develop a program to compute N! using unsigned integer type of array to store; for a N from 1 to 99,999,999.  The result can be a very long number. For example, the factorial of 50 is:

30,414,093,201,713,378,043,612,608,166,064,768,844,377,641,568,960,512,000,000,000,000

In the main method, you ask user to enter factorial number N to compute and create unsigned integer type of an array with 5000 elements to store result of factorial number. Pass an array to the function by reference so that when execution returns from the function and an array will contain final factorials number. The function will compute N! and store into array with a maximum 5 digits per element.

In order to solve this problem, you will initialize the first element of array that it contains 1! Before computing the factorial requested by the user. The factorial of zero and the factorial of one is one (2! is 2, 3! is 6, 4! is 24...etc).  You need to design how you want to store number into array from 0 to 5000 element or 5000 to 0 element, which is very important when you design your display method.

Write a method to compute the factorial of a number using the algorithm described in class. This should be as efficient as possible. You should store a maximum 5 digits per element and perform computation for large factorials.

Write a method to display the factorial you computed. As you print the value in each element of array you will need to fill in leading zeros by printing character zeros if the digits in an element of the array (except for the beginning of the number) contains leading zeros. Do not print commas in the numbers as shown above. You can only display 60 characters per line. Print to the screen the factorial number you were computing, the number of digits in the value, and print all the digits in the number that was computed.

After you have printed the results, as the user to input the next integer number to be used to compute a factorial. Terminate the program when the user enters a negative number.

You should find out what is biggest factorial number that your program can compute and how long to finished (time)? (Wire the answer of this question in the comment section at the beginning of the program)




Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a C program that implements the requirements you specified include iostream include vector inc... 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

International Marketing And Export Management

Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr

8th Edition

1292016922, 978-1292016924

More Books

Students also viewed these Algorithms questions

Question

Evaluate each expression if possible. -V0.49

Answered: 1 week ago

Question

Do any of my ideas contradict one another?

Answered: 1 week ago

Question

What is e-business?

Answered: 1 week ago