Chapter 18: Problem 11
(Greatest Common Divisor) The greatest common divisor of integers \(x\) and \(y\) is the largest integer that evenly divides into both \(x\) and \(y .\) Write a recursive method gcd that returns the greatest common divisor of \(x\) and \(y .\) The gcd of \(x\) and \(y\) is defined recursively as follows: If \(y\) is equal to 0 then \(\operatorname{gcd}(x, y)\) is \(x ;\) otherwise, \(\operatorname{gcd}(x, y)\) is \(\operatorname{gcd}(y, x \% y),\) where \(\%\) is the remainder operator. Use this method to replace the one you wrote in the application of Exercise 6.27
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.