HCF:
Stand for Highest common factor.
Example-
HCF of 8 and 12 is 4
HCF of 5 and 7 is 1
HCF of 5 ad 10 is 5
program:
#include < iostream>
using namespace std;
class r4r{
int a,b,lcm;
public:
int get_value()
{
cout<<"Enter first number"<< endl;
cin>>a;
cout<<"Enter second number"<< endl;
cin>>b;
}
int find_hcf()
{
int min,i;
if(a< b)
min=a;
else
min=b;
for(i=min;i>0;i--)
{
if(a%i==0 && b%i==0)
{
cout<<"HCF is "<< i;
break;
}
}
}
};
int main()
{
r4r obj;
obj.get_value();
obj.find_hcf();
return 0;
}
Enter first number
10
Enter second number
12
HCF is 2