C Programming Code Examples C > Recursion Code Examples C Program to Find GCD of given Numbers using Recursion C Program to Find GCD of given Numbers using Recursion This C program, using recursion, finds the GCD of the two numbers entered by the user. The user enters two numbers by using a space in between them or by pressing enter after each input. #include <stdio.h> int gcd(int, int); int main() { int x, y, result; printf("Enter the two numbers to find their GCD: "); scanf("%d%d", &x, &y); result = gcd(x, y); printf("The GCD of %d and %d is %d.\n", x, y, result); } int gcd(int x, int y) { while (x != y) { if (x > y) { return gcd(x - y, y); } else { return gcd(x, y - x); } } return x; }}