About:
The HCF or GCD of two integers is the largest integer that can exactly divide both numbers (without a remainder).
For example:81 and 153
The gcd(81,153)=9.
Program:
The HCF or GCD of two integers is the largest integer that can exactly divide both numbers (without a remainder).
For example:81 and 153
The gcd(81,153)=9.
Program:
#include<stdio.h>
void main()
{
int n1,n2,gcd;
printf("Enter any two no:");
scanf("%d%d",&n1,&n2);
for(int i=1;i<=n1&&i<=n2;++i){
if(n1%i==0&&n2%i==0)
gcd=i;
}
printf("The gcd of %d and %d=%d",n1,n2,gcd);
}
No comments:
Post a Comment