Check out example codes for "greatest common denominator recursion c++". It will help you in understanding the concepts better.

Code Example 1

#include <iostream>
using namespace std;
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}
int main() {
   int a , b;
   cout<<"Enter the values of a and b: "<<endl;
   cin>>a>>b;
   cout<<"GCD of "<< a <<" and "<< b <<" is "<< gcd(a, b);
   return 0;
}

Code Example 2

int gcd(int a, int b){
   if(b==0)
      return a;
    return gcd(b, a % b);
}

Learn ReactJs, React Native from akashmittal.com