C program to print gcd of two numbers using recursion
Output:
Enter two numbers to find its GCD:
12 15
GCD of 12 & 15 is3
Implementation:
Output:
Enter two numbers to find its GCD:
12 15
GCD of 12 & 15 is3
Implementation:
#include <stdio.h>
int findgcd(int m,int n)
{
if(m==0)
return n;
if(n==0)
return m;
return findgcd(n,m%n);
}
int main(void) {
int m,n;
printf("Enter two numbers to find its GCD:\n");
scanf("%d %d",&m,&n);
printf("GCD of %d & %d is %d",m,n,findgcd(m,n));
return 0;
}