Solution Review 1: Find the Greatest Common Divisor
This lesson provides a detailed review of the solution to the challenge in the previous lesson.
We'll cover the following...
We'll cover the following...
Solution
Understanding the Code
In the code above, the function gcd is a recursive function as it makes a recursive call in the function body. Below is an explanation of the above code:
Driver Function
-
In the
main()code, we have defined three integer variables:x,yandresult. -
resultstores the greatest common divisor ofxandywhen thegcdfunction is called. -
line 30 ...