15. (Numerical) a. Euclid’s method for finding the greatest common divisor (GCD) of two positive integers consists of the following steps: Step 1: Divide the larger number by the smaller and retain the remainder. Step 2: Divide the smaller number by the remainder, again retaining the remainder. Step 3: Continue dividing the previous remainder by the current remainder until the remainder is zero, at which point the last non-zero remainder is the GCD.
Please write a C++ coding with modularity using functions.
15. (Numerical) a. Euclid’s method for finding the greatest common divisor (GCD) of two positive integers consists of the following steps:
Step 1: Divide the larger number by the smaller and retain the remainder.
Step 2: Divide the smaller number by the remainder, again retaining the remainder.
Step 3: Continue dividing the previous remainder by the current remainder until the remainder is zero, at which point the last non-zero remainder is the GCD.
For example, if the two positive integers are 84 and 49, you have the following:
Step 1: 84/49 yields a remainder of 35.
Step 2: 49/35 yields a remainder of 14.
Step 3: 35/14 yields a remainder of 7.
Step 3: 14/7 yields a remainder of 0.
Therefore, the last non-zero remainder, which is 7, is the GCD of 84 and 49.
Using Euclid’s
thank you in advance
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images