GCD USING RECURSION - C-Tutorial

Latest

Monday, 26 September 2016

GCD USING RECURSION

/* PROGRAM FOR GCD */


#include<stdio.h>
#include<conio.h>

int rgcd(int,int);
main()
{
int m,n;
clrscr();
printf("\n Enter m,n values:\t");
scanf("%d%d",&m,&n);
printf("\n GCD = %d",rgcd(m,n));
getch();
}

int rgcd(int m,int n)
{
if(n==0)
return m;
else
return rgcd(n,m%n);
}

No comments:

Post a Comment