Question
C++ The Greatest Common Divisor (gcd) of two or more (consider only positive non-zero) integers is the largest positive integer that divides the numbers without
C++ The Greatest Common Divisor (gcd) of two or more (consider only positive non-zero) integers is the largest positive integer that divides the numbers without a remainder. For instance, the GCD of 8 and 12 is 4. Write a function named computeGCD that takes two user inputted positive integer arguments and returns the greatest common divisor of those two integers. If the function is passed an argument that is not greater than zero, then the function should return the value -1 to indicate than an error occurred. For instance:
cout << computeGCD(8, 12); // output: 4
cout << computeGCD(256, 625); // output: 1
cout << computeGCD(0, 8); // output: -1
cout << computeGCD(10, -2); // output: -1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started