A formula for finding the greatest common divisor (GCD) of two numbers was formulated by the mathematician Euclid around 300 BCE. The GCD of two numbers is the largest number that will divide into both numbers without any remainder. For example, the GCD of 12 and 16 is 4, the GCD of 18 and 12 is 6.
The basic algorithm is as follows:
If you divide one number by another, you will have a quotient and a remainder. If the remainder is 0, the divisor is the GCD.
If the remainder is greater than 0, divide the remainder into the divisor. If the new remainder is 0, the new divisor (the old remainder) is the GCD. If the new remainder is greater than zero repeat this step (divide the new remainder into the new divisor).
Write a recursive method that finds the GCD of two numbers using Euclid's algorithm.