GCD
mian()
{
int a,b ;
printf("Enter two positive integers :\n");
scanf("%d%d",&a,&b);
printf("GCD of %d and %d is %d\n",a,b,gcd(a,b));
}
gcd(int a,int b)
{
if(a)
return(b?gcd(b,a%b):a);
else
return b;
}
OUTPUT
Enter two positive integers
24 36
GCD of 24 and 36 is 12
mian()
{
int a,b ;
printf("Enter two positive integers :\n");
scanf("%d%d",&a,&b);
printf("GCD of %d and %d is %d\n",a,b,gcd(a,b));
}
gcd(int a,int b)
{
if(a)
return(b?gcd(b,a%b):a);
else
return b;
}
OUTPUT
Enter two positive integers
24 36
GCD of 24 and 36 is 12
No comments:
Post a Comment