Bhuvan InfoTech Android App

Download our Android App and browse Technical News, Projects, Computer Tricks more easily with lots of Interesting Features.

Tuesday, June 14, 2016

Find Greatest common divisor | C program


#include<stdio.h>
int gcd(int,int);

int main()
{
 int a,b;
 printf("Type 2 values to find GCD :\n");
 scanf("%d %d",&a,&b);
 printf("GCD : %d",gcd(a,b));
 return 0;
}

int gcd(int m,int n)
{
 if(n>m) return gcd(n,m);
 if(n==0) return m;
 return gcd(n,m%n);
}
Bhuvan Arora

No comments:

Amazing Deal !