#include <iostream>
// Function prototype for computing the greatest common divisor (GCD)
int gcd(int a, int b);
int main() {
// Declare and initialize two numbers
int a = 12, b = 20;
// Call the gcd function and store the result
int _gcd = gcd(a, b);
// Output the greatest common divisor (GCD)
std::cout << "The GCD (greatest common divisor) of " << a << " and " << b << " is: " << _gcd;
return 0;
}
// Recursive function to compute the GCD
int gcd(int a, int b) {
// Base case: if b is 0, return a as the GCD
return b == 0 ? a : gcd(b, a % b); // Recursive call with b and remainder of a divided by b
}
/*
run:
The GCD (greatest common divisor) of 12 and 20 is: 4
*/