/* File: p5test3.c Use Euclid Algorithm for greatest common divisors (gcd) to check that recursive function calls and the return statement works. */ #include void gcd (int a, int b) { int remainder, quotient ; if (a < 0 || b < 0) { printf("Don't use negative numbers!!!\n") ; return ; } if (b == 0 ) { printf ("gcd(%d, %d) = %d\n", a, b, a) ; return ; } quotient = a / b ; /* note: integer division */ remainder = a - quotient * b ; printf("gcd(%d, %d) = ", a, b) ; gcd(b, remainder) ; } main() { int n, m ; printf("Enter first number: ") ; scanf("%d", &n) ; printf("Enter second number: ") ; scanf("%d", &m) ; gcd(n,m) ; }