Euclid's GCD Algorithm

Suman Barik
0
#include <iostream>

using namespace std;

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

int main(){
    int a = 98, b = 56;
    cout<<"GCD of "<<a<<" and "<<b<<" is "<<gcd(a, b);
    return 0;
}

//GCD of 98 and 56 is 14

Post a Comment

0Comments
Post a Comment (0)