GCD

Description:

Program to find GCD of two given numbers Test Case 1 Input (stdin) 25 5 Expected Output 5 Test Case 2 Input (stdin) 32 84 Expected Output 4

Program :

#include<iostream>

using namespace std;

int gcd(int a, int b) {

   if (a == 0 || b == 0)

      return 0;

   else if (a == b)

      return a;

   else if (a > b)

      return gcd(a-b, b);

   else return gcd(a, b-a);

}

int main() {

   int a,b;

  cin>>a>>b;

   cout<< gcd(a, b);

   return 0;

}