Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two programs to calculate the factorial of a given input integer in two ways: a. Use a for loop b. Use recursion Your

 

Write two programs to calculate the factorial of a given input integer in two ways: a. Use a for loop b. Use recursion Your results variable must be an unsigned long long (64b). Test your programs and make sure they work. What is the maximum input value without causing an overflow (results needs to be correct)? After testing your programs, you will use a Linux system utility/command called "time" to time these two programs with the maximum input value. Run these two programs 5 times each with "time". Record your results and calculate the average of these runs for each program. Turn in a table of your timing values. Discuss what you have observed. Change you program to have results in "double". What is the max input value not resulting in "inf"? Run your two programs with the max input value 5 times each and record the running time with the Linux system command "time". Discuss what you have observed from these results.

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

Computer Organization And Design The Hardware Software Interface

Authors: David A. Patterson, John L. Hennessy

4th Revised Edition

0123747503, 978-0123747501

More Books

Students also viewed these Algorithms questions

Question

Discuss whether happier people make more money.

Answered: 1 week ago