gcd in c++

C++
// CPP program to illustrate 
// gcd function of C++ STL 
#include <iostream> 
#include <algorithm>  
  
using namespace std; 
  
int main() 
{ 
    cout << "gcd(6, 20) = " << __gcd(6, 20) << endl; 
} 
int gcd(int a, int b) 
{ 
    // Everything divides 0  
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
    // base case 
    if (a == b) 
        return a; 
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
}
Source

Also in C++: