C language - Calculate the greatest common divisor of two numbers

ht‮/:spt‬/www.lautturi.com
C language - Calculate the greatest common divisor of two numbers

get the GCD:

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
int main()
{
    int a = 40, b = 72;
    printf("the GCD of %d and %d is %d", a, b, gcd(a, b));
    return 0;
}
Created Time:2017-08-28 18:41:34  Author:lautturi