#include<stdio.h>
#include<conio.h>
// recursive function to find gcd of two number
int gcd(int a, int b)
{
if(b!=0)
return gcd(b, a%b); // general case
else
return a; // base case
}
int main()
{
int n1, n2, result;
printf("Enter any two numbers: ");
scanf("%d %d",&n1,&n2);
result = gcd(n1,n2);
printf("GCD of %d and %d = %d",n1,n2,result);
getch();
return 0;
}
Enter any two numbers: 45
40
GCD of 45 and 40 = 5
--------------------------------
Process exited after 9.672 seconds with return value 0
Press any key to continue . . .