Find GCD of a number using recursion c program
Find GCD of a number using recursion c program,
C programming source code to find GDC using recursion,
Find Gretest Common Divisor of a number using recursion in c program solve example with source code
#include
int
main(){
int n1,n2,gcd;
printf("\nEnter two numbers: ");
scanf("%d %d",&n1,&n2);
gcd=findgcd(n1,n2);
printf("\nGCD of %d and %d is: %d",n1,n2,gcd);
return 0;
}
int findgcd(int x,int y){
while(x!=y){
if(x>y)
return findgcd(x-y,y);
else
return findgcd(x,y-x);
}
return x;
}