Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

One of the first algorithms written in a book is known as the Euclidean algorithm. It describes a method for finding the Greatest Common

 

One of the first algorithms written in a book is known as the Euclidean algorithm. It describes a method for finding the Greatest Common Divisor (GCD) of two positive integers. The GCD of two integers can help to reduce a fraction to a proper form (for example, 9/12 reduces to 3/4). In school you likely learned another method called factorization to do this that is, you factored the two integers and then reduced the fraction by crossing out common terms. Description of GCD Euclidean Algorithm 1. Start with two positive integers. 2. Replace the larger integer with the difference of the two integers. 3. Repeat the second step until the two integers are the same (this value is the GCD). Example of Euclidean Algorithm (18, 6)-> (12, 6)-> (6, 6) Detailed remarks: Initial pair of values: (18, 6) LOOP: next step, replace the larger value, 18, with (186) or 12 resulting in (12, 6) LOOP: next step, replace the larger value, 12, with (126) or 6 resulting in (6, 6) LOOP: stop the loop since the two values in the pair (6, 6) are the same. Therefore, the GCD of (18, 6) is 6. Write a C++ program that asks the user to enter a fraction (HINT: checkpoint 3.5). The program should implement the GCD algorithm described above to then reduce the fraction. The output of the program should show the original fraction, the reduced fraction and the computed GCD. Show the following three test cases with your screen shots: 3 / 12 1386 / 3213 105 / 252

Step by Step Solution

3.47 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

To find all the functional dependencies that are satisfied by the given relation we need to analyze ... 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

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions