GREATEST COMMON FACTOR (GCF)
It is also known as Greatest Common Divisor and Highest Common Factor.
The GCF of numbers X and Y is the biggest number that will divide both X and Y,
GCF is the product of all the factors that X and Y have in common.
For example,
X=20= 2*2*5
Y=30=2*3*5
GCF=2*5=10
LEAST COMMON MULTIPLE (LCM)
The LCM of X and Y is the smallest number (non zero) that is a multiple of both X and Y.
For example,
X=20=2*2*5
Y=30=2*3*5
LCM=60
PROGRAM
//Program to find GCF and LCM of a number
#include<iostream>
using namespace std;
int main()
{
int a, b, x, y ,t, gcd, lcm;
cout<<"ENTER TWO INTEGERS:\n";
cin>>x>>y;
a=x;
b=y;
while (b != 0)
{
t = b;
b = a % b;
a = t;
}
gcd = a;
lcm = (x*y)/gcd;
cout<<"GREATEST COMMON FACTOR OF "<<x<<" AND "<<y<<" IS:"<<gcd<<endl;
cout<<"LEAST COMMON MULTIPLE OF "<<x<<" AND "<<y<<" IS:"<<lcm;
return 0;
}
OUTPUT