Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the Consecutive Integer Checking algorithm for finding the greatest common divisor of two positive integers m and n as a procedure or method in

Implement the Consecutive Integer Checking algorithm for finding the greatest common divisor of two positive integers m and n as a procedure or method in a programming language of your choice. Include a counter in your implementation to record the number of integers that are checked before the answer is found for each pair of input. Write a main program to generate 100 pairs of integers randomly between 1000 and 20,000 and call the consecutive integer checking method for each pair. Determine which pair requires the most number of iterations, which pair requires the least number of iterations, and the average number of iterations overall. Output from your program should look like the following:

The most number of iterations used is (?) for GCD(?, ?) = ?. The least number of iterations used is (?) for GCD(?, ?) = ?. The average number of iterations used for all 100 pairs is (?).

Each question mark (?) above should show a specific number.

Implement the Euclids algorithm as a procedure or method in the same way and gather the output result for the same 100 pairs of randomly generated integers. Compare the output results from the two solutions and describe the difference in the number of iteractions used.

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_2

Step: 3

blur-text-image_3

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions