Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. [25 pts] Write two programs to calculate the factorial of a given input integer in two ways: a. Use a for loop b.

image text in transcribed

1. [25 pts] 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. 2. [25 pts] 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. Turn in your program as well as screen capture for running your program besides answering questions and discussion.

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

=+1. What is the schedule for this project?

Answered: 1 week ago

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago