#include<iostream>
using namespace std;
int main()
{
int p, q, n1, n2, t, gcf, lcm;
cout<<"Enter the two numbers : ";
cin >> n1 >> n2; // read the two numbers
p = n1;
q = n2;
while (q != 0) // calculate gcf
{
t = q;
q = p % q;
p = t;
}
gcf = p;
lcm = (n1 * n2) / gcf; // calculate lcm
cout << "GCF of two numbers " << n1 <<" and "
<< n2 << " is : " << gcf << endl; // print
gcf
cout << "LCM of two numbers "<< n1 <<" and "
<< n2 << " is : " << lcm; // print lcm
return 0;
}
OUTPUT :
Get Answers For Free
Most questions answered within 1 hours.