Question: Write a C++ function named gcd that accepts two integer parameters and returns their greatest common divisor using Euclidean Algorithm. You can use recursion.

Write a C++ function named gcd that accepts two integer parameters and returns their greatest common divisor using Euclidean Algorithm. You can use recursion. You can convert the parameters to positive if they are negative. Some examples are given below: gcd (3,10) should return 1. gcd (21,15) should return 3. gcd(-16,24) should return 8.
Step by Step Solution
There are 3 Steps involved in it
Answer code is as follow include iostream Function to calculate the greatest common divisor GCD usin... View full answer
Get step-by-step solutions from verified subject matter experts
