In Class Recursion

A few weeks ago, we wrote a program for a Fraction Class. We wrote a function to find the greatest common divisor of two numbers, using a loop.  Can we write this recursively?

Euclid's algorithm for finding the greatest common divisor of two integers is the following:

The  greatest common divisor of two integers m and n with m > n  can be defined as follows:

           n, if n divides m evenly

           otherwise, it is the same as the greatest common divisor of n and m mod n

 

1. ON PAPER, write the recursive algorithm, describing the base case(s) and recursive case(s) carefully.

2. Code the solution in C++.