C Program to calculate GCD by Recursion
#include<stdio.h>
#include<conio.h>
void main()
{
int gcd(int,int);
int a,b,g;
;
scanf("%d %d",&a,&b);
clrscr();
g=gcd(a,b);
printf("\n");
printf(" gcd = %d",g);
getch();
}
int gcd(int a,int b)
{
int hcf;
if(a%b==0)
return (b);
else
{
hcf=gcd(b,a%b);
return (hcf);
}
}
No comments:
Post a Comment