FIND GCD OF A NUMBER USING RECURSION IN C PROGRAM
Solution:
#include<stdio.h>
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;
}
More C Program :
- FIND GCD OF A NUMBER USING RECURSION IN C PROGRAM
- write a c program to find gcd of two numbers using recursion
- gcd program in c without recursion
- gcd of two numbers using recursion in java
- gcd using recursion in c language
- c program to find factorial of a number using recursion
- fibonacci using recursion
- write a c program for finding gcd of two given numbers
- c program to find gcd of two numbers using functions